Page 1 of 1

receive and display specified and filtered products on page?

Posted: 11 Nov 2017, 22:30
by Ahmad
i have a home page for my aimeos laravel shop,
i want to show in this page on different section a list of products,
for example:
In one section, the list of products that have the most sales,
In the other section, see the list of popular products,
In one section, the list of products that have special discounts (not regular discounts),
In one section, the product list is a specified category

i want to get this lists in home page controller (For example, in the form of an array) with label/title in locale language, photos, price and stocklevel and show them in view


Please guide me as you can

Re: receive and display specified and filtered products on p

Posted: 12 Nov 2017, 12:02
by aimeos
For performance reasons it's best to organize your products in different categories and fetch them via the product controller (https://aimeos.org/api/latest/class-Aim ... Iface.html):

Code: Select all

$context = $this->app->make('\Aimeos\Shop\Base\Context')->get();
$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'product' );
$filter = $filter->addFilterCategory( $cntl->createFilter(), <catid> );
$items = $cntl->searchItems( $filter, ['text', 'price', 'media'] );
Otherwise, you would have to aggregate over all orders to see if which products have the most sales or define somehow what are popular products or products with "special" discounts.

Stock levels must be retrieved separately for the products (https://aimeos.org/api/latest/class-Aim ... Iface.html):

Code: Select all

$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'stock' );
$filter = $filter->addFilterCodes( $cntl->createFilter(), <list of product codes> );
$stockItems = $cntl->searchItems( $filter );
The the "catalog/lists" component, this is done in a separate request for performance reasons because stock levels can't be cached like the rest of the product data.