Magento export a list of product missing images

In this article, I will show you how to make a module which exports products without images into a CSV file. This is a requirement I had to do for one of our recent projects. You might need to have this when you setup products for your online store. I suggest that you should have programming skill to have this done. I will try to make it a module when I have free time.

I assume that you will create one module for it, let's call it "CustomProductExport". In this module, I will write everything in only one file: IndexController.php. You will need other files for your modules, such as config.xml and Namespace_CustomProductExport.

The most important function in controller is exportAction(). In this method, we will get a list of products which do not have images and put them into a CSV file. Here is the PHP code I used to get that list of products.

$catalog_product_entity = $this->_getTableName('catalog_product_entity');
$catalog_product_entity_varchar = $this->_getTableName('catalog_product_entity_varchar');
$image_attribute_id = $this->_getProductAttributeId('image');

$query = "SELECT cpe.entity_id FROM ".$catalog_product_entity." cpe JOIN ".$catalog_product_entity_varchar." cpev
ON cpe.entity_id=cpev.entity_id AND cpev.attribute_id=".$image_attribute_id."
WHERE cpev.value IS NULL";

And here is how you can put all products in a CSV file.

$file_path   = Mage::getBaseDir() . DS .'media' . DS . 'products.csv';
$mage_csv = new Varien_File_Csv(); //mage CSV
$mage_csv->saveData($file_path, $products);

I attached my controller file for your reference. After finishing it, you just need to run the action in browser and then download CSV file through FTP client in media folder. Download File.

5 thoughts on “Magento export a list of product missing images”

5 Responses to Magento export a list of product missing images

  • David Radovanovic

    Neo, this is what I've been looking for: a way to output a file of all products' missing files. Can you give some more detailed advice for a Magento beginner? Any help would be great.

  • Neo

    David, Can you give me your email? I will contact you for more detail so that I can help you.

  • Habib

    Hi Neo,

    Great article. I am curious to know if it is possible to export list of products in the cart to a FTP server (in a csv format) upon checkout?


  • Neo

    Habib, I don't really understand what you are looking for. Do you need to export a list products in shopping cart when customers checkout? And this list will be saved in your server as a CSV file?

  • jane

    Hello Neo,

    I am also interested in your solution and a Magento beginner? Could you please provide some instructions on how to implement this?