Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to run a query to find a list of products with no images assigned to them? Ideally I'd like SKUs printed out on the screen.

share|improve this question
up vote 10 down vote accepted

You can find the collection for below code.

$_products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter(array(
        array (
            'attribute' => 'image',
            'like' => 'no_selection'
        ),
        array (
            'attribute' => 'image', // null fields
            'null' => true
        ),
        array (
            'attribute' => 'image', // empty, but not null
            'eq' => ''
        ),
        array (
            'attribute' => 'image', // check for information that doesn't conform to Magento's formatting
            'nlike' => '%/%/%'
        ),
    ));

you can got all product list which has no Images assign.

share|improve this answer
    
Works great, thank you. – Francis Kim Jun 16 '14 at 6:50

If you want only the products that don't have image, small_image or thumbnail assigned then the answers from @KeyulShah or @TBIInfotech will give you just that.

If you want the products that have no images at all, you can run this query on the database and get them.

SELECT
    e.sku, COUNT(m.value) as cnt
FROM
    catalog_product_entity e 
    LEFT JOIN catalog_product_entity_media_gallery m
        ON e.entity_id = m.entity_id
GROUP BY
    e.entity_id
HAVING
    cnt = 0

If you remove the having statement you will get a 2 column result with the product skus and the number of images assigned to them.

You can just export that as a csv.

share|improve this answer

Just a small modification to what @keyul shah described, just put the code on magento root:

<?php 

require 'app/Mage.php';
Mage::app();
$_products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter(array(
        array (
            'attribute' => 'image',
            'like' => 'no_selection'
        ),
        array (
            'attribute' => 'image', // null fields
            'null' => true
        ),
        array (
            'attribute' => 'image', // empty, but not null
            'eq' => ''
        ),
        array (
            'attribute' => 'image', // check for information that doesn't conform to Magento's formatting
            'nlike' => '%/%/%'
        ),
    ));

foreach($_products as $_product){

    echo $_product->getSku();

}
share|improve this answer
    
Your solution worked great, I've given you an upvote but will award the answer to the original post. – Francis Kim Jun 16 '14 at 6:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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