0

I'm trying to load the Admin Text Label instead of the translated Default store view label but can't figure out how to do it.Been searching for an answer for days.

<?php 
$sportTypes = explode(",",$_product->getResource()
->getAttribute('foodpair')->getFrontend()
->getValue($_product));

foreach($sportTypes as $key => $value){
        echo $value;
    }
 ?>

The problem is, I can only get the default store label but not the admin one :(

0

If I am understanding correctly you just want the Label. Your code will show the value, not the label. For example if that attribute is a Yes/No, your code sample will show "No" or "Yes" when it echo's.

If you want the label you need to change your syntax slightly:

$sportTypes = explode(",",$_product->getResource()
->getAttribute('foodpair')->getFrontend()
->getLabel($_product));

foreach($sportTypes as $key => $value){
    echo $value;
}

I just did a bit of testing and created a new attribute with 8 websites. Each website I had a different string for the label. When I used

$label = $_product->getResource()
->getAttribute('foodpair')->getFrontend()
->getLabel($_product)

My $label had a value of the default Store enter image description here

Now for the webpage view of the $label

enter image description here

1
  • this is what i want but for the options instead of the attribute – user1787355 Dec 19 '15 at 19:57

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.