Force image loading directly from media folder

This is helpful when cache is inconsistent. In item.phtml,

insert

<?php
    $storeId = Mage::app()->getStore()->getId();
    if ($pdfItem['type'] == 'configurable') {
        //get simple product sku
        $simpleProductSku = $pdfItem['productDetails']['Sku'];
        //get Id of the simple product
        $simpleProductId = Mage::getModel('catalog/product')->getResource()->getIdBySku($simpleProductSku);
        $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($simpleProductId);
    }
    else {
        $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($pdfItem['productId']);
    }
    $prodImage = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
 
?>

NOTE: for stores that use CDN, this might work:

$prodImage = str_replace('cdn.cdndomain.com', 'www.domain.com', $prodImage);

Still need help? Contact Us Contact Us