I have multi-select attribute name location like : Delhi , Maharashtra, Karnataka.

I want to use sort by of filter by in such way when I use above filter / sort it should show all products but product with matching attributes should show on top.

for example if I am using filter/sort with value as Maharashtra all products should show on listing page but products with value Maharashtra will be on top .

I can not find any way to do same please help with it how can it be done.

  • Have you created attribute ? – Pawan Oct 25 '19 at 3:47
  • yes we have created attribute – user1799722 Oct 25 '19 at 10:50
  • just like position, name and price work ? – Pawan Oct 25 '19 at 16:50
  • @Pawan can u help with issue – user1799722 Nov 1 '19 at 16:08
  • will try, do you want same as position and name work in sort option ? – Pawan Nov 1 '19 at 17:06

You have to override listing page product collection block. Separately get collection of products base on location, then append both collections.

|improve this answer|||||

Create New Product Attribute: In the tab: Properties Default Label: Location Catalog Input Type for Store Owner: Dropdown OR Multiple Select Values:add your location

Storefront properties: Use in Layered Navigation: Filterable(with result)

After assign this attribute to product set and run: php bin/magento c:f

Finally in category page showing.

|improve this answer|||||
  • please read my question is bit different – user1799722 Oct 25 '19 at 12:43

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.