$categories = Mage::getModel('catalog/category')
    ->setOrder('entity_id', 'DESC')

// For each category do
foreach ($categories as $_category) {
    // Get products collection and add attributes to select
    $products = $_category->getProductCollection();

    // For each product do
    foreach ($products as $_product) {
       $storeId = 14;
       $product = Mage::getModel('catalog/product');
       if (is_object($product)) {
           $imageObj = Mage::helper('catalog/image')->init($_product, 'image');
           $urlIm = $imageObj->__toString();
           $imageUrl[] = $urlIm;

I tried to get url's of cached product full images for store 14, but always receiving url's for store 0.


You can also use Mage_Core_Model_App_Emulation class:

$storeId = 14;
$appEmulation = Mage::getSingleton('core/app_emulation');

# Start environment emulation of the specified store
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);

$products = Mage::getModel('catalog/product')->getCollection();
foreach ($products as $_product) {

# Stop environment emulation and restore original store

Note: if you use flat tables, you'll only get image path of enabled products.

Source: http://inchoo.net/magento/emulate-store-in-magento/

  • Thanks sv3n, how could i put this data in json file? any code after or before foreach? – Sushant Thorat Jul 8 '17 at 11:49
    $savedStoreId = Mage::app()->getStore()->getId();
    $storeId = 14;
     /*** all my code for receive product data ****/
    // return to saved Store 

I have received correct data for selected store only when I change current store. In another case, I had not access to the data cached another store.

  • 1
    have added an example of using the store filter on the initial collection. – Jon Holland Aug 4 '16 at 10:03

Try changing the line




Personally I would concatenate those lines into one:

$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());

Also the line:

$imageObj = Mage::helper('catalog/image')->init($_product, 'image');

should be using $product and not $_product as $product is the one you have set the storeId for.

You could also try adding a store filter to the initial collection:

$categories = Mage::getModel("catalog/category")->getCollection()->addStoreFilter($storeId)->setOrder("entity_id","DESC")->addAttributeToSelect("name");
  • Thank's now when i try: $_product->getStoreId() - receving 14, but cach url I receive for 0 strore: $imageObj = Mage::helper('catalog/image')->init($_product, 'image'); $picUrl = $imageObj->__toString() – Boulatov Aug 1 '16 at 11:51
  • 1
    $imageObj = Mage::helper('catalog/image')->init($_product, 'image'); is using $_product and not $product. I have added this to my answer – Jon Holland Aug 1 '16 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.