How to get attribute value in magento 2.0.6 product view and list page
-
01-10-2020 - |
Question
How to get product attribute value in magento 2.0.6 product view page and list page
Solution
In product view page you can get like this:
$this->getProduct()->getId();
$this->getProduct()->getName();
You can get custom attribute like this:
$attribute = $this->getProduct()->getResource()->getAttribute('attribute_id');
if ($attribute)
{
$brick_value = $attribute->getFrontend()->getValue($this->getProduct());
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange