Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#4944 by aimeos
12 Nov 2017, 11:40
Add the "catalog/lists" component to your controller action that is rendering the home page: https://aimeos.org/docs/Laravel/Create_new_pages
Please read https://aimeos.org/docs/Laravel/Adapt_pages too.

Add your top seller products to the "home" category (the root category node). In the action for the home page, configure the default category ID of your "home" category (https://aimeos.org/docs/Configuration/Core/client/html/catalog/lists/catid-default):
Code: Select all$context = $this->app->make('\Aimeos\Shop\Base\Context')->get();
$context->getConfig()->set( 'client/html/catalog/lists/catid-default', 123 );
#4950 by Ahmad
12 Nov 2017, 13:11
aimeos wrote:Add the "catalog/lists" component to your controller action that is rendering the home page: https://aimeos.org/docs/Laravel/Create_new_pages
Please read https://aimeos.org/docs/Laravel/Adapt_pages too.

Add your top seller products to the "home" category (the root category node). In the action for the home page, configure the default category ID of your "home" category (https://aimeos.org/docs/Configuration/Core/client/html/catalog/lists/catid-default):
Code: Select all$context = $this->app->make('\Aimeos\Shop\Base\Context')->get();
$context->getConfig()->set( 'client/html/catalog/lists/catid-default', 123 );


Thank you, but you did not understand my question correctly

I want to get a list of the top 10 products that have the most sales
In other words, I want to get a list of 10 products, bought by customers more than other products
Also, consider that the products may be in different categories, but it does not matter which category they are to get the list
Or if we want to specify that the products with the most sales are in this category, we specify that if they are in category 1 or 2 or 3 or any category id that i set.

i want to get this list with product controller as an array

please help me and if you can code it for me...
#4960 by aimeos
13 Nov 2017, 15:55
If you want to evalute the top seller products dynamically, you first have to find out which products are sold most:
Code: Select all$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' );
$filter = $manager->createSearch();
$result = $manager->aggregate( $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\Factory::createController( $context, 'product' );
$items = $cntl->getProductItems( <ids>, ['text', 'price', 'media'] );


We always suggest to do this once a day in a job controller instead and populate a special category with that products!