I created a new drop-down custom product attribute and placed it in an attribute set. and I'm trying to retrieve its value programmatically in Magento 2. The name of said attribute is "ee_qty_custom" but for some reason, I always get either 1 or an empty array when I use any and all functions including:
- getattribute('ee_qty_custom')
- getattributetext('ee_qty_custom')
- getData('ee_qty_custom')
Best Answer
You can get the atrribute value by:
First code will give you the value of option and second one will give you text. Both code should work.
Tip: If your code is not showing on front, make sure you set
Used in Product Listing
toyes
in Storefront Properties of attribute!