Magento 1.8 – Get Product Name Related to Store View in Admin

magento-1.8

I have created two store views for two different languages, english and arabic. I displayed the store view at admin form for my module just above tabs as shown below:

enter image description here

When i select a store view, the page reloads and in module form i place the following code:

$storeId = $this->getRequest()->getParam();

$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($storeId);
  foreach($products as $p)
    {
        $p->load($p->getId);

        if($p->getId() == 166)
        {
            echo $p->getName();
        }

I have different names for each store view, but here i only get the name for the default store view which is English, and i want the name of the product entered for that specific store view.

I have used the below code to get the product store ids for checking:

$p->getStoreIds(); 

and i get correct ids for my store views which are 1 for english and 4 for arabic.

I am not sure if i am doing it correct or wrong, but can some one provide me some guidance here?

Thank you

Best Answer

If you call $p->load($p->getId()); without specifying a store view, you will get the default values.

Try this instead.

$p->setStoreId($storeId)->load($p->getId());
Related Topic