2

I have a 'size' attribute with lot of option. For each option, I have translation for each my stores :

size attribute

I want to get the translation label for a product and for a given store.

So :

I load my product

$prod = Mage::getModel('catalog/product')->setStoreId(1)->load($productId);

Then I try to get label :

$label = $prod->getResource()->getAttribute('size')->getFrontend()->getValue($prod);

But I always get the default value : here "TU" (store 0) instead of "Taille Unique" (store 1).

If I try to get the label with this code :

$label = $prod->getAttributeText('size');

Now, I get "One Size" (store 2) instead of "Taille unique" (store 1) and it's really weird, isn't it ?

What is wrong in my code ?

  • What happens if you do $prod->getData()? – Haim Nov 6 '18 at 13:21
  • That return the data of my product (and the store is egal to 1) – Kozame Nov 6 '18 at 13:51
0

Please use below code:

$prod->getResource()->getAttribute('size')->setStoreId(1)->getFrontend()->getValue($prod);
  • That return "TU" (store 0) :/ – Kozame Nov 6 '18 at 13:16
  • make sure you can add proper store id in setStoreId() – Bhavin iFlair Nov 6 '18 at 13:16
  • What's mean ? I can write "setStoreId()" but then, that don't set the store ? – Kozame Nov 6 '18 at 13:22
  • Please see in my answer, i wrote setStoreId(1) just for example, you can replaced your store id and this is working fine for me here..thank you – Bhavin iFlair Nov 6 '18 at 13:26
  • I use your "setStoreId(1)" but that return me the value of the store 0 (default store) – Kozame Nov 6 '18 at 13:30

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.