On the product page (within the "column main" area) I have created a phtml file. In this I want to echo all the chosen options of a custom multiselect attribute.
What I have:
current product (via
name of my custom attribute (xyz)
for example 3 selected options out of 5 (e.g. "red", "green" and "black")
What I need:
- The three values of the selected options
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance();?> <?php $currentProduct = $objectManager->get('Magento\Framework\Registry')->registry('current_product'); //get current product ?> <?php echo $currentProduct->getCustomAttribute('xyz')->getValue(); ?> <?php echo $currentProduct->getAttributeText('xyz'); ?>
But there is no output.
I found a lot of possible solutions using
->getResource() but I have come to learn this method is deprecated as from 2.3.