我以编程方式复制产品,但我不想要orgiginal Picture - 我只想要一个在我的服务器上的默认图像。
我该怎么办?我不明白: - /
$clone = $product->duplicate();
$clone->setSku('Generator');
$clone->setName('Ihre Konfiguration / Bestellung');
$clone->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
$clone->setStatus(1);
$clone->setVisibility(4);
$clone->setTaxClassId(2);
$clone->setCategoryIds("93");
$clone->getResource()->save($clone);
这必须是我在“克隆 - >保存之前”尝试过的代码,但如何设置图像文件夹的路径?
$clone->setMediaGallery (array('images'=>array (), 'values'=>array ()));
$clone->addImageToMediaGallery ($fullImagePath, array ('image','small_image','thumbnail'), false, false);
答案 0 :(得分:0)
$filePath = "../media/product/img_import/img.jpg";
$clone->addImageToMediaGallery($filePath, array('image', 'small_image', 'thumbnail'), false, false);
$clone->save();