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 :(

1 Answer 1

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 Commented Dec 19, 2015 at 19:57

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.