I want to get custom attribute like this in product detail enter image description here
How can i do that?
Any help? Thank in advance.
asked Feb 4, 2020 at 2:47
MichaelHa
6611 gold badge8 silver badges24 bronze badges
-
You want this in custom admin form?Kishor Thummar– Kishor Thummar2020年02月04日 03:54:40 +00:00Commented Feb 4, 2020 at 3:54
1 Answer 1
Try this to get all options
protected $eavConfig;
public function __construct(
...............................
\Magento\Eav\Model\Config $eavConfig,
...............................
) {
...............................
$this->_eavConfig = $eavConfig;
...............................
}
public function execute()
{
$attributeCode = "your_attributr_name";
$attribute = $this->_eavConfig->getAttribute('catalog_product', $attributeCode);
$options = $attribute->getSource()->getAllOptions();
$arr = [];
foreach ($options as $option) {
if ($option['value'] > 0) {
$arr[] = $option;
}
}
}
Reference from click here
answered Feb 4, 2020 at 3:36
Msquare
9,4627 gold badges30 silver badges71 bronze badges
default