0

I am working on a site that uses Mageplaza Layered Navigation in Porto Theme.

I need to change the behavior of multiselect from OR to AND.

As an example, I create attribute color. When I search for blue and red, it should only show products that are blue AND red.

Multiselect is correctly set, the only problem is to change the code - I cannot find where should I change.

2
  • 1
    Are you using LayeredNavigation Ultimate or Free? Aug 3, 2019 at 0:05
  • I am using Free ! Aug 4, 2019 at 22:38

2 Answers 2

0

To make multi-select with AND behaviour in Mageplaza LayeredNavigation, you will have to edit initObserve function of app/code/Mageplaza/LayeredNavigation/view/frontend/web/js/layer.js where you have to set the logic for allowing to select multiple links(passing multiple values in url for example: base url/category url?color=51,49 ) & then to edit collection you have to set logic in public function apply(\Magento\Framework\App\RequestInterface $request) of app/code/Mageplaza/LayeredNavigation/Model/Layer/Filter/Attribute.php file for attributes, Similarly for category edit app/code/Mageplaza/LayeredNavigation/Model/Layer/Filter/Category.php, for price

app/code/Mageplaza/LayeredNavigation/Model/Layer/Filter/Price.php & for decimal type edit app/code/Mageplaza/LayeredNavigation/Model/Layer/Filter/Price.php/Decimal.php

2
  • It looks like you solved the puzzle :) Thank you very much for your help !!!! Aug 4, 2019 at 22:38
  • Thank You @GustavoUlyssea :)
    – Mona Mehta
    Aug 5, 2019 at 13:50
1

in the class Attribute when I filter:

$productCollection->addFieldToFilter($attribute->getAttributeCode(), ["finset" => $filters]);

with elasticsearch mode, I have the following error: {"type":"parsing_exception","reason":"[terms] unknown token [START_ARRAY] after [finset]","line":1,"col":228}

What could be causing the error? Thanks

1
  • If it's answer describe more.
    – Msquare
    Mar 26, 2020 at 3:21

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.