Page 1 of 1

Filter products by order amount?

Posted: 28 Nov 2022, 14:56
by kdim95
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.

Re: Filter products by order amount?

Posted: 29 Nov 2022, 09:28
by aimeos
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?

Re: Filter products by order amount?

Posted: 29 Nov 2022, 14:26
by kdim95
Yes, I want to sort by the amount of orders, I will also go ahead and upgrade the version.

Re: Filter products by order amount?

Posted: 29 Nov 2022, 16:03
by aimeos
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.