I have some thousand products and want to find all products without an image. I tried to search for (no image) in the admin products grid, but no result. How can I make an S
I only want to add that the answer of Sean Michaud is right except we don't need to use that
array (
'attribute' => 'image', // null fields
'null' => true
),
Using that page: http://bytes.com/topic/sql-server/answers/83267-wildcard-doesnt-match-using-like-varchar-field-wierd
"A NULL value is not the same as a string of zero length. NULL represents the absence of any value, and the SQL standard says that a NULL value is never equal to any other value including another NULL"
So %/%/% won't get the NULL values, but adding the code from above we will fix the error and get the image fields with NULL values. This is the result
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(array(
array (
'attribute' => 'image', // null fields
'null' => true
),
array (
'attribute' => 'image', // check for information that doesn't conform to Magento's formatting
'nlike' => '%/%/%'
),
));
If you want to work with all image attributes, the code could be like this
$products = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(array(
array (
'attribute' => 'image', //Check for information that doesn't conform to Magento's formatting
'nlike' => '%/%/%'
),
array (
'attribute' => 'small_image', //Check for information that doesn't conform to Magento's formatting
'nlike' => '%/%/%'
),
array (
'attribute' => 'thumbnail', //Check for information that doesn't conform to Magento's formatting
'nlike' => '%/%/%'
),
array (
'attribute' => 'image', //Check for null fields
'null' => true
),
array (
'attribute' => 'small_image', //Check for null fields
'null' => true
),
array (
'attribute' => 'thumbnail', //Check for null fields
'null' => true
),
));