Filter products by order amount?

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
kdim95
Advanced
Posts: 195
Joined: 26 Aug 2022, 12:17

Filter products by order amount?

Post by kdim95 » 28 Nov 2022, 14:56

Laravel framework version: 9.41.0
Aimeos Laravel version: * 2022.07.2
PHP Version: 8.1.12
Environment: Linux

What's the best way to do this?

The file I'm redacting is a customized version of ai-client-html/src/Client/Html/Catalog/Lists/Standard.
I'm changing the filtering inside data() function.

I am planning to add a new "orders" column to the mshop_product table and modify the Orders manager to update that column on a new order, but I want to know if there is a more efficient way to do it.

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

Re: Filter products by order amount?

Post by aimeos » 29 Nov 2022, 09:28

Please upgrade to 2022.10 LTS as previous 2022.x version are not supported any more.

What is the exact use case? Do you want to sort products by the number of orders they are in?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

kdim95
Advanced
Posts: 195
Joined: 26 Aug 2022, 12:17

Re: Filter products by order amount?

Post by kdim95 » 29 Nov 2022, 14:26

Yes, I want to sort by the amount of orders, I will also go ahead and upgrade the version.

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

Re: Filter products by order amount?

Post by aimeos » 29 Nov 2022, 16:03

Then, adding a new column and a product decorator for managing it would be the best option to get search results fast:
https://aimeos.org/docs/latest/models/extend-managers/

You can use a decorator for the order base manager too to update the new column.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply