I have been working on our site to download the images for specific SKUs. I am fetching the images like following

$sku = $_REQUEST['sku'];
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
$_images = $product->getMediaGalleryImages();
$url = array();
foreach ($_images as $image) {
   $url[] =  str_replace('https:' , 'http:',$image->getUrl());
echo implode("|||" , $url);

It works well for the enabled products, but images for disabled products can't be fetched using this snippet. Can anybody help me out to load disabled product images by SKU?

  • Does your Magento install use flat tables?
    – Rob
    Commented May 14, 2015 at 12:02
  • Yes it does @Rob
    – Gogol
    Commented May 14, 2015 at 12:20
  • I will refine my answer once back at a computer. But when loading a collection with flat tables "on" it will not return disabled products unless you load it in the context of the admin store. I'd start there. I'll post more once I'm on.
    – Rob
    Commented May 14, 2015 at 12:27

1 Answer 1


As per as magento system loadByAttribute() get item from Collection and magento does not provide all data of product from product Collection... See at Class Mage_Catalog_Model_Abstract

 public function loadByAttribute($attribute, $value, $additionalAttributes = '*')
        $collection = $this->getResourceCollection()
            ->addAttributeToFilter($attribute, $value)

        foreach ($collection as $object) {
            return $object;
        return false;

If magento collect product collection at frontend then magento remove all Disable product Collection.

So that you need use load function.

Or use Current store as admin by Changing




Also,check the link for getting media image faster ways.See the link

Faster way to load media images in a product collection

  • Changing Mage::init(); to Mage::app('admin'); does the trick thanks!
    – Gogol
    Commented May 14, 2015 at 13:01

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.