문제

Created a custom product attribute by programmatically. Now, I need to get the drop down option values in a phtml page.

$seriesname  =   $child->getAttributeText('series');

$values =   $product->getResource()->getAttribute('series')->getFrontend()->getValue($product);

$_attributeValue = $block->getProduct()->getResource()->getAttribute('series')->getFrontend()->getValue($block->getProduct());

Used the above three methods, but I didn't get all the values. I only get 'Select Option'. It has three option values, option1, option2, option3

도움이 되었습니까?

해결책

You can use this

$attr = $product->getResource()->getAttribute('series');
if($attr->usesSource()) {
    $allOptions = $attr->getSource()->getAllOptions(true, true);
    var_dump($allOptions);die;
}

다른 팁

You can get it by below code

$_attributeValue = $block->getProduct()->getResource()->getAttribute('series')->getFrontend()->getValue($block->getProduct());
$values =   $product->getResource()->getAttribute('series')->getFrontend()->getValue($product);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top