How to get products of specific category.
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 86
- Joined: 12 Jan 2019, 15:17
How to get products of specific category.
Please tell me method so that i can get the products of specific category.
and please tell me the function that i can get
name
Media URL
Description
Attributes
Price
and please tell me the function that i can get
name
Media URL
Description
Attributes
Price
Re: How to get products of specific category.
In 2018.10:
In upcoming 2019.04:
Code: Select all
$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'product' );
$filter = $cntl->createFilter( 'relevance', '+', 0, 48 );
$filter = $cntl->addFilterCategory( $filter, '<catid>' );
$products = $cntl->searchItems( $filter, ['attribute', 'media', 'price', 'text] );
foreach( $products as $product )
{
$name = $product->getName();
$url = current( $product->getRefItems( 'media', 'default', 'default' ) )->getPreview(); // or ->getUrl()
$desc = current( $product->getRefItems( 'text', 'default', 'long' ) )->getContent();
$attributes = $product->getRefItems( 'attribute', null, 'default' );
$price = current( $product->getRefItems( 'price', 'default', 'default' ) )->getValue();
}
Code: Select all
$products = \Aimeos\Controller\Frontend::create( $context, 'product' )
->uses( ['attribute', 'media', 'price', 'text] )->category( '<catid>' )
->sort( 'relevance' )->slice( 0, 48 )->search();
// rest same as above
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star