/* Remove Product media Image Start*/
$ptoductId=120;
$productImgRemov= Mage::getModel('catalog/product')->load($ptoductId);
$entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
$mediaGalleryAttribute = Mage::getModel('catalog/resource_eav_attribute')->loadByCode($entityTypeId, 'media_gallery');
$gallery = $productImgRemov->getMediaGalleryImages();
foreach ($gallery as $image)
$mediaGalleryAttribute->getBackend()->removeImage($productImgRemov, $image->getFile());
$productImgRemov->save();
/* Remove Product media Image End*/
$ptoductId=120;
$productImgRemov= Mage::getModel('catalog/product')->load($ptoductId);
$entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
$mediaGalleryAttribute = Mage::getModel('catalog/resource_eav_attribute')->loadByCode($entityTypeId, 'media_gallery');
$gallery = $productImgRemov->getMediaGalleryImages();
foreach ($gallery as $image)
$mediaGalleryAttribute->getBackend()->removeImage($productImgRemov, $image->getFile());
$productImgRemov->save();
/* Remove Product media Image End*/
Comments
Post a Comment