receive and display specified and filtered products on page?

Help for integrating the Laravel package
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!
Ahmad
Posts: 72
Joined: 05 Jul 2017, 15:19

receive and display specified and filtered products on page?

Post by Ahmad » 11 Nov 2017, 22:30

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

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

Re: receive and display specified and filtered products on p

Post by aimeos » 12 Nov 2017, 12:02

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply