0

I've created a product attribute in the admin panel and have added it to a product. These attributes are now showing within the tabs on the frontend, however I would like them to appear between the product short description and the SKU.

I've added the following code in the correct location within view.phtml, and this is showing correctly on the frontend if only one option is selected

<?php echo $_product->getAttributeText('product_use'); ?>

However if there are multiple items selected then the only thing that will show up on the front end is the word array

1 Answer 1

0

It depends on how you have managed the select attribute from backend, If the managed data type is an array, then While fetching the data on front end you will have to use "foreach" Use this below example to display multi select data,

if ($multiSelectArray = $_product()->getAttributeText('product_use')) {
    if (is_string($multiSelectArray)) {
    $multiSelectArray = array($multiSelectArray);
    }
    foreach ($multiSelectArray as $multiSelectItem) :
   //add your code here.
    endforeach;
}
1
  • 2
    That's excellent, thank you very much for your help! Jun 7, 2019 at 8:15

Your Answer

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

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