top products by customer, controller, view
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
top products by customer, controller, view
Hi,
we'd like to provide in the customer-profiles a list of their 10 most frequently bought products. (quantity of products / customer).
I already found this forum post: laravel-package-f18/how-can-get-bestsel ... t1193.html
Does "order.base.product.quantity" already takes order-quantities by customers into account or do we have to add the current customer id?
We created a new controller with the code above. Is it possible to use / copy the default Aimeos product list “html client” / view, that is already used for our product catalog? How would the controller look like?
Thank you!
we'd like to provide in the customer-profiles a list of their 10 most frequently bought products. (quantity of products / customer).
I already found this forum post: laravel-package-f18/how-can-get-bestsel ... t1193.html
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'order/base/product' );
$result = $manager->aggregate( $manager->filter(), 'order.base.product.productid', 'order.base.product.quantity', 'sum' );
// find the products which are sold most in $result (product ID is the key, count is the value)
$cntl = \Aimeos\Controller\Frontend::create( $context, 'product' );
$items = $cntl->uses( ['text', 'price', 'media'] )->product( <ids> )->search();
We created a new controller with the code above. Is it possible to use / copy the default Aimeos product list “html client” / view, that is already used for our product catalog? How would the controller look like?
Thank you!
Re: top products by customer, controller, view
As your filter is empty, the result wouldn't be limited to the customer. The customer ID is stored in the mshop_order_base table, so the code must be something like this:
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'order/base' );
$filter = $manager->filter()->add( 'customer.id', '==', '<customer id>' );
$result = $manager->aggregate( $filter, 'order.base.product.productid', 'order.base.product.quantity', 'sum' );
The catalog/list component doesn't contain that code so it won't work that way but you can create a new "account/top10" component and use the templates of the catalog/list component:
https://aimeos.org/docs/latest/frontend ... omponents/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,
