Magento – How to exclude product images programatically

imagemagento-1.9product

I want to mark some of the product images as excluded against some products. I tried this link http://www.magecoders.com/blog/2013/05/programmatically-exclude-product-images-in-magento/ so far. But didn't work.

Best Answer

I had the same issue. I managed to exclude the images by removing them using the same code but with a small change. Before doing any of the following, BACKUP your database.

Change this

$mediaApi->update($_product->getId(),$item['file'],$data);

To this

$mediaApi->remove($_product->getId(),$item['file']);

It will remove the image from displaying in admin, but the actual image will remain under media folder.

Regards, Daniel