skip to Main Content

We have been trying to make a query when a user apply some filters on front end. We are trying to make OR query in products collection: tried the following but none of them work

$collection->addAttributeToFilter(['web_mobile_filter','offer_group_name_value'],
            [
                ['in' => '1122'],
                ['in' => '72']
            ]);

and

  $collection->addAttributeToFilter(
        [
            [
                'attribute' => 'web_mobile_filter',
                'in' => '1122'
            ],
            [
                'attribute' => 'offer_group_name_value',
                'in' => '72,73'
            ],
        ]
    );

Can someone help me, find me what i am doing wrong here please?

2

Answers


  1. You can write like this :-

    $collection->addAttributeToFilter( 'web_mobile_filter',
                [         
                    'in' => '1122'
                ]);
    
    Login or Signup to reply.
  2. $collection->addAttributeToFilter(array( array('attribute' => 'special_price','null' => true), array('attribute' => 'product_in_stock','eq' => 1)), '', 'left' );
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search