empty result when get category product

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
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

empty result when get category product

Post by ahmed31916 » 29 Apr 2022, 03:32

I'm trying to get products list for category id = 1.
This code should get it

Code: Select all

$tree = \Aimeos\Controller\Frontend::create( $context, 'catalog' )->uses( ['catalog', 'media', 'supplier', 'text', 'product'] )
->getTree( \Aimeos\Controller\Frontend\Catalog\Iface::LIST )->getPath( 1 );
$products = $tree->getRefItems( 'product', null, 'promotion' );
but it returns empty result. Why?
Attachments
Screenshot 2022-04-29 063404.png
Screenshot 2022-04-29 063404.png (3.22 KiB) Viewed 572 times

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

Re: empty result when get category product

Post by aimeos » 29 Apr 2022, 05:31

This will return the catalog root node but no products.
Use this to get the promotional products for category with ID 1:

Code: Select all

$products = \Aimeos\Controller\Frontend::create( $context, 'product' )
	->uses( ['catalog', 'media', 'supplier', 'text', 'product'] ) // use 'product' only if you need the variants/referred products too
	->category( 1, 'promotion' )
	->search();
Have a look at the interface for the available methods:
https://github.com/aimeos/ai-controller ... /Iface.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

Re: empty result when get category product

Post by ahmed31916 » 29 Apr 2022, 11:28

thank you

Post Reply