Sort products

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
traiyani75
Advanced
Posts: 114
Joined: 08 Nov 2019, 11:56

Sort products

Post by traiyani75 » 14 May 2020, 17:11

Hello,

We are using JSON APIs into mobile application for eCommerce. Now, We have end point to get all products and get all products by category.
We have option to assigned them position into categories products. But we are not able to get those products by position.
If we call api to get products without any filters then it is working, but if we pass category id using filter[f_catid] then products are not sorted as per admin position

Regards

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Sort products

Post by aimeos » 17 May 2020, 09:09

You must use

Code: Select all

<product endpoint>?filter[f_catid]=123&sort=relevance
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

traiyani75
Advanced
Posts: 114
Joined: 08 Nov 2019, 11:56

Re: Sort products

Post by traiyani75 » 17 May 2020, 20:31

I have tried but its it not working with category filter. I set position for multiple products and tried end point with
sort=relevance and sort=-relevance. Both time result is same

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Sort products

Post by aimeos » 19 May 2020, 07:39

"-relevance" doesn't exist. If you add filter[f_catid]=10 to the JSON REST API URL of the product endpoint, the returned list of products is automatically sorted by the positions you've assigned to the product references in the catalog panel of the admin interface.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
QuốcTrungNguyễnHoàng
Posts: 14
Joined: 06 Aug 2019, 03:22

Re: Sort products

Post by QuốcTrungNguyễnHoàng » 12 Nov 2020, 07:06

Sorry it not working,
It still sort by product.id
Image
Both add sort: 'relevance' or not add with filter: {f_catid: categoryId}
It work after i'm rebuild index

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Sort products

Post by aimeos » 15 Jul 2021, 09:14

Only one price is stored in the mshop_index_price table and this is the one customers can sort by. If you want to sort by several price types (default and listprice for example), you would have to extend the table by the price type, extend the index price manager to store prices of all types and extend the frontend controller and/or the HTML client to pass the price type to the filter.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

TGergo
Posts: 41
Joined: 24 Nov 2022, 14:35

Re: Sort products

Post by TGergo » 06 Jan 2023, 10:51

Small bug:

Sort by Rating works well.
But It won't be bold, when selected.

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Sort products

Post by aimeos » 06 Jan 2023, 12:28

Thanks for the hint! This has been fixed now in aimeos/ai-client-html dev-master and 2022.10.x-dev
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply