1. i have to call an ajax request from an external website which (the simple way) returns the link to an product image of a store view i added to the request. The problem is, that the following function call always returns the path from the default store view, cause the request is to the default store.

        ->init($product, 'image')
    1. If the calling site is a https site, the website can't show the image, because it's loaded from a non https site.

So there are two questions:

  1. How can i load an image path of a specific store view id?
  2. How can i load the image path with the secure base url?

Thanks in advance for any help!

4 Answers 4


The quick and dirty way is to strip the protocol designator and turn it into a Protocol Relative URL:

// This assumes $product is from a collection that is constructed including a call to:
// Mage_Catalog_Model_Resource_Category_Collection::setProductStoreId()
$url = $this->helper('catalog/image')
    ->init($product, 'image')
$url = preg_replace('#^https?://#, '//', $url);

You can try below code first of all call helper of catalog

echo  Mage::helper('catalog/image')->init($product, 'thumbnail');

From this code you can get cache path also.

$item should be an instance of Mage_Catalog_Model_Product so you should be able to get the image url using the catalog image helper:

$imageUrl = (string)Mage::helper('catalog/image')->init($item, 'image');

So your code should look like this (only the section that should display the image)

<div class="image_product">
    <a href="<?php echo $item->getProductUrl(); ?>">
       <img src="<?php echo Mage::helper('catalog/image')->init($item, 'image')/*->resize(200, 200)*/; ?>" alt="<?php echo $item->getName();?>" />

If you want the image at a specific size, just uncomment the resize method and change the width and height.

Have you tried this?


I think that gets you the base secure url, I believe.

  • That's exactly the way i tried before? So the function returns the image path with the base path of the defalt store view. I wanna have the image path with the basepath from a specific store view. Commented Nov 18, 2014 at 10:36
<?php echo Mage::helper('catalog/image')->init($products,'small_image')->resize(210); ?>

From what I can see, people are answering point 2 of your question but not point 1...

To get the path for a specific store view, you have to apply that store view id to the product before loading it. For example:

 * some code to work out what $storeId and $productId are
$product = Mage::getModel('catalog/product')

And then your code should work as desired.

If the product has been loaded already you can still use the above code to reload it (just use $product->getId() in place of $productId above).

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.