Querying data - top 5 products

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!
User avatar
bilginkilic
Posts: 34
Joined: 05 Jul 2020, 07:08

Querying data - top 5 products

Post by bilginkilic » 21 Jul 2020, 08:26

$items = Product::uses(['text', 'media', 'price','name'])
->category(1)
->sort('name')->slice(0, 48)->search();

how to put site_id condition an extra filter like product limitation, etc in this query?

major point is.. how to fetch limited product..

Like i want to list only 5 items.

ps: current query is picking product price is in euro and usd both..

We wanted to pick only based on store configuration.
@bilginkilic_ (twitter)

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

Re: Querying data - top 5 products

Post by aimeos » 23 Jul 2020, 08:13

To add a site ID filter and limit the items to 5, use:

Code: Select all

$items = Product::uses(['text', 'media', 'price','name'])
    ->compare('==', 'product.siteid', '<site ID string>')
    ->category(1)->sort('name')->slice(0, 5)->search();
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply