0

I have two custom product attributes. both attribute type is Multiselect. I want a product collection using a filter of both attributes.

I have tried with below solution but it not working.

$productCollection->addAttributeToFilter(
            array(
              array('attribute'=>'configurator_room', 'finset'=>271983),
              array('attribute'=>'configurator_light_location_recommendation', 'finset'=>272001),
          )
        );

1 Answer 1

1

You can try addFieldToFilter, using objectmanager just to test obviously not recomended

 <?php
    use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
    
    $productCollectionFactory = $objectManager->get(CollectionFactory::class);
    
    $productCollection = $productCollectionFactory->create();
    $attrCode = 'filter_size';
    $collection = $productCollection->addAttributeToSelect('*')->addFieldToFilter(
    'filter_size', ['finset'=>"197"]->addFieldToFilter('manufacturing_parts', ['finset'=>"27"]);
    print_r($collection->getData());
1
  • is this possible to update logic for the entire PLP and search result page, please add your inputs Commented Aug 13 at 13:35

Your Answer

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

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