Counting of the sold goods in each SKU.

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!
User avatar
ЕвгенияСемихова(ИПСемиховаЕ.А.)
Posts: 70
Joined: 11 Jan 2025, 09:45

Counting of the sold goods in each SKU.

Post by ЕвгенияСемихова(ИПСемиховаЕ.А.) » 28 Feb 2025, 06:15

At my old site was count of selling items.

Image

Q: have Aimeos this functional? Place in database? Or necessary to add a new record to the database and make a separate query?
How will this be done more correctly, taking into account further Aimeos updates?
Debian 12, PHP 8.3, Server 1 = Aimeos 2024.10.13, Server 2 = ES 8.17.1
life is full of many new and interesting things

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

Re: Counting of the sold goods in each SKU.

Post by aimeos » 28 Feb 2025, 16:10

This isn't available yet in Aimeos and you have to create an own project specific Aimeos extension:
https://aimeos.org/docs/latest/developer/extensions/

Then, implement a HTML client decorator for the catalog/detail component:
https://aimeos.org/docs/latest/frontend ... omponents/

In the data() method of the decorator, add:

Code: Select all

$manager = \Aimeos\MShop::create( $this->context, 'order' );
$filter = $manager->filter()->add( 'order.product.productid', '==', $this->get( 'detailProductItem' )?->getId() );
$view->productsOrdered = $manager->aggregate( $filter, 'order.product.productid', 'order.product.quantity'', 'sum' )->first();
Finally, overwrite the catalog/detail template in your own extension and output the "productsOrdered" value:
https://aimeos.org/docs/latest/frontend ... templates/

This is save for updating because you don't change any code in the vendor directory which would be overwritten each time the package is updated.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply