3

我正在以编程方式复制产品,但我不想要原始图片 - 我只想要我服务器上的默认图像。

我该怎么办?我不明白:-/

    $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 -> save 之前”尝试过的代码,但是如何将路径设置为 imagefolder?

    $clone->setMediaGallery (array('images'=>array (), 'values'=>array ()));
    $clone->addImageToMediaGallery ($fullImagePath, array ('image','small_image','thumbnail'), false, false);
4

1 回答 1

0
$filePath = "../media/product/img_import/img.jpg";
$clone->addImageToMediaGallery($filePath, array('image', 'small_image', 'thumbnail'), false, false);
$clone->save();
于 2014-10-01T10:59:55.587 回答