2

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

1

2 Answers 2

1

You can use this

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

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);

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.