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.

3 Answers 3

1

It working fine with following syntax.

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

Change this

 $collection1->setStore(1);

to

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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