I would like to know, the process to get list of comparable attributes of a product with their label/name and their values.

i'm using this, but it's not working.

$attributes = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection');

$productCollection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');

$collection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');

foreach ($attributes as $attribute) 

can anyone know. thanks in advance.


You have to set visitor Id for collection first and then get comparable attributes

like this

$attributes = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection')->setVisitorId($visitorId);

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.