1

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

2

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());
  • It worked. Can you please explain to me that then what is the purpose of addStoreFilter at collection? – Altaf Hussain Mar 27 '14 at 9:58
  • If you are in the backend it has not effect. On frontend I think it joins with the price index table for that specific store view or something like that. – Marius Mar 27 '14 at 10:01
  • Yes, you are right, it has no effect on backend. Just removed adStoreFilter and still it is working fine. Thanks for the answer. – Altaf Hussain Mar 27 '14 at 10:05

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.