0

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');
            $attributes->getComparableAttributes();

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

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

foreach ($attributes as $attribute) 
            {
                $collection->addAttributeToSelect($attribute->getAttributeCode());
            }
           $collection->load();
            $collection->setPageSize(1);

can anyone know. thanks in advance.

0

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);
$attributes->getComparableAttributes();

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.