0

My code is this:

$simple_product->getAttributeText('attribute')

I would display attribute text value in his different language in my view.phtml. If i use getAttributeText('attribute') it shows me the value of the admin column of the attribute and not in other languages. I attached a screen for this:

enter image description here

This operation I want to perform on the associated products of the configurable product and therefore I extracted the value of the attribute as follows:

$simple_collection = $conf->getUsedProductCollection()- 
>addAttributeToSelect('*')->addFilterByRequiredOptions();

foreach($simple_collection as $simple_product){$simple_product- 
 >getAttributeText('color');
}

How can i do?

1 Answer 1

0

Try this

  $StoreAttrValue = $_product->getResource()->getAttribute('attribute_name')->setStoreId({{store_id}})->getFrontend()->getValue($_product);

Or

You have to set store ID.

$storeId = Mage::app()->getStore()->getStoreId();
$_product->setStoreId($storeId)->getAttributeText('my_attribute');
5
  • Hi i tried this but not work, i update my question because I had not written something
    – Gabriel91
    Commented May 24, 2018 at 8:33
  • Try to reindex data.
    – MR.R DNATH
    Commented May 24, 2018 at 8:42
  • The error that brings me back is this: Call to a member function setStoreId() on null. I tried but ever with the same result.
    – Gabriel91
    Commented May 24, 2018 at 8:51
  • Try next code & let me know
    – MR.R DNATH
    Commented May 24, 2018 at 9:31
  • I tried man, not report to me anything error but show only admin value and not the translated value
    – Gabriel91
    Commented May 24, 2018 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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