Skip to content

Instantly share code, notes, and snippets.

@barbazul
Created March 25, 2013 12:35
Show Gist options
  • Save barbazul/5236813 to your computer and use it in GitHub Desktop.
Save barbazul/5236813 to your computer and use it in GitHub Desktop.
Get a collection of products without image, ordered by an attribute
<?php
require_once 'app/Mage.php';
Mage::app();
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(array('name', 'sku', 'isbn'))
->addAttributeToFilter('image', array('null' => true))
->addAttributeToSort('editorial');
foreach ($collection as $product) {
echo "Product " . $product->getSku() . " has no image\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment