0

I have some code to get the product in my block template:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');

Is there a method that I can call to get me a list of all of the product attributes ?

Something like :

$_product->getAttributes();

Thanks.


I can use this (my bad) :

$attrs =  $_product->getAttributes();
foreach( $attrs as $attr ){
}
  • Do you want to list out all product attributes with their respective value for that product? – Mohit Kumar Arora Dec 5 '18 at 13:01
1

Try below code.

$attrs = $_product->getAttributes();

foreach($attrs as $a) {

    echo $a->getName()."\n";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.