Count of sold products
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 8
- Joined: 11 Nov 2020, 15:09
Count of sold products
I want to display a counter, how many products have been sold in the webshop.
I want to show on the startpage, that 100pcs of a certain product grouped by a certain custom attribute are already sold.
Is there an easy way to do this?
Or do i have to make variants of the attributes and use the stock levels for this?
I want to show on the startpage, that 100pcs of a certain product grouped by a certain custom attribute are already sold.
Is there an easy way to do this?
Or do i have to make variants of the attributes and use the stock levels for this?
Re: Count of sold products
The stock level only tells you how many pieces are still available, not how many you have sold.
You have to implement a bit of custom code for that and use the order product manager to count the sold product using:
The result is a list of key/value pairs of product ID and sold quantity. You need the product IDs for filtering or you may be able to filter by the attribute IDs attached to the ordered product if there's any (i.e. if it's a variant attribute you are looking for or you can use hidden attributes for that).
You have to implement a bit of custom code for that and use the order product manager to count the sold product using:
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'order/base/product' );
$filter = $manager->filter()->add( ['order.base.product.productid' => $prodIds] );
$result = $manager->aggregate( $filter, 'order.base.product.productid', 'order.base.product.quantity', 'sum' );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star