Tuesday, 4 September 2018

Magento 2: Get product attribute’s select option id,label for configurable product




<?php
    $_helper = $this->helper('Magento\Catalog\Helper\Output');
    $_product = $block->getProduct();
    $optionId = $_product->getColor()
?>


$attr = $_product->getResource()->getAttribute('color');
 if ($attr->usesSource()) {
       $optionText = $attr->getSource()->getOptionText($optionId);
 }

1 comment: