Saturday 22 October 2016

How to get a product attribute options by code Magento2 ?

How to get a product attribute options by code Magento2


with the below code we can get the attribute options at any place of magento2

like templates , controllers etc


$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$manufacturerOptions = $objectManager->create('\Magento\Catalog\Model\Product\Attribute\Repository')->get('manufacturer')->getOptions();
foreach ($manufacturerOptions as $manufacturerOption) ;
echo $manufacturerOption->getValue();
echo $manufacturerOption->getLabel();















No comments:

Post a Comment