0

I am try to filter Product collection attribute Multi Select with Following code but it not working with IN or FINESET.

\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory 

$collection1 = $this->collectionFactory->create();
$collection1->setStore(1);
$collection1->addAttributeToFilter('industry', array('in' => array(7)));

Suppose Product attribute "industry" contain 8,7,2 In this case above filter not working.

anyone have idea about this.

1

It working fine with following syntax.

$collection->addAttributeToFilter($attribute,
    array(
        array('finset'=> array('237')),
        array('finset'=> array('238')),
        array('finset'=> array('239')),
    )
);
| improve this answer | |
0

Change this

 $collection1->setStore(1);

to

 $collection1->setStore(0);
| improve this answer | |
0
$collection1 = $this->collectionFactory->create();
$collection1->setStore(1);
$collection->addAttributeToSelect('*');
$collection->addFieldToFilter('industry', ['in' => [2, 7, 8]]);
| improve this answer | |
  • I have check with above syntax but getting same result. – Niranjan Gondaliya Sep 5 '18 at 4:29
  • @NiranjanGondaliya code edited – Vinz Sep 5 '18 at 14:40

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.