开发者

Magento - can't delete programmatically imported pictures

I hase used this code :

require_once("app/Mage.php");
Mage::app();


$fullImagePath = "app/code/local/Mycompany/Import/data/images/test_picture.jpg";

$product = Mage::getModel('catalog/product');
$product->load(16);

$product->setMediaGallery (array('images'=>array (), 'values'=>array ()));
$product->addImageToMediaGallery ($fullImagePath, array ('image'), false, false); 
$product->save();

to import pictures to a product.

开发者_JS百科

The problem in that is that when I delete the programmatically imported picture from the backend, it stay always visible in frontend.

I don't know what's wrong in my code.

Thanks for help.


I think in your import code instead of doing setMediaGallery() and hard coding your image url you should,

$config = $product->getMediaConfig(); 
//and get your file url from the set media path in your config.
$fileurl = $config->getMediaUrl('sth/test_picture.jpg');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜