0

In product collection, I want to do like :

$productCollection = $this->productCollectionFactory->create();
$productCollection->addCategoriesFilter(['in' => $catalog_id])->addAttributeToSelect('*');
$productCollection->addAttributeToFilter('color', ['eq' => 2650]);
$productCollection->addAttributeToFilter('size', ['eq' => 10]);

This above code working properly. But, my attribute collection will be dynamically. So, I want to do like just single addAttributeToFilter and this both filter apply.

How to do that?

Any help would be appriciated.

0

wel you can make array and add it there like that :

$productCollection->addAttributeToFilter(array('color', ['eq' => 2650]), ('size', ['eq' => 10]));

or just create a foreach loop to process your array

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.