Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: Get product price from another store?

I have multi-store Magento installation, and different product prices are set in different stores. I want to display on one page the actual product price from the current store, and the price from other store (I have its ID), but I'm not sure how to get that info?

The prices are set for each store view for each product, no tier-pricing or special-pricing was used.

like image 661
Relja Avatar asked Mar 08 '11 16:03

Relja


1 Answers

If you know the storeId, set in setStoreId :

/**
 * call the Magento catalog/product model
 * set the current store ID
 * load the product
 */
$product = Mage::getModel('catalog/product')
            ->setStoreId($storeId)
            ->load($key); 

Display in a block :

echo $product->getName();

We can also use print_r to see the values :

print_r($product->getData()); 

The following code will show current store ID :

$storeId    = Mage::app()->getStore()->getId();

To get all product ID's with each store view :

$product    = Mage::getModel('catalog/product');
$products   = $product->getCollection()->addStoreFilter($storeId)->getData();

If you change the $storeId will show different product.

like image 83
Oğuz Çelikdemir Avatar answered Nov 15 '22 18:11

Oğuz Çelikdemir