getRequest()->getParam('sku'); if ($sku !== null) { $_product = Mage::getModel('catalog/product')->load(Mage::getModel('catalog/product')->getIdBySku($sku)); if ($_product->getId() > 0) { try { $url = Mage::helper('catalog/image')->init($_product, 'image')->resize(150); $type = null; switch(end(explode('.', $url))){ case "jpg": case "jpeg": $type = "jpeg"; break; case "png": $type = "png"; break; case "gif": $type = "gif"; break; } if($type !== null){ $imageData = $this->url_get_contents($url); if($imageData !== false){ header('Content-Type: image/'.$type); echo $imageData; } } } catch (Exception $e) { } } } } /** * Returns the url * * @param string $url * @return mixed */ public function url_get_contents ($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); curl_close($ch); return $output; } }