0

Can anyone help me find products that have no images assigned to them.

Either a list of products with no images or a way to delete them using a PHP script would be ideal

Thank you

1
  • I assume you are talking about the image gallery images. Commented Nov 7, 2013 at 17:35

1 Answer 1

0
$collection = Mage::getResourceModel('catalog/product_collection')
    ->addAttributeToFilter('media_gallery', array('isnull' => true))

should give you all the products.

$collection->delete();

should delete them all.

But be careful, if the filter is wrong, you might delete all products!

4
  • There is no delete() on a collection unless you implement it yourself, e.g. stackoverflow.com/a/7820188 Commented Nov 12, 2013 at 7:50
  • I'm sorry, there is, here: \Mage_Eav_Model_Entity_Collection_Abstract::delete() Commented Nov 12, 2013 at 10:09
  • Oh well... spent too much time in Mage_Core_Model_Resource_Db_Collection_Abstract it seems ;-) It's funny that one class has it implemented and not the other. Commented Nov 12, 2013 at 13:21
  • Absolutely, should be moved up in the inheritance chain ! :) Commented Nov 12, 2013 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.