Question

How to get product attribute value in magento 2.0.6 product view page and list page

Was it helpful?

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
scroll top