How to filter only promotion products?
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!
How to filter only promotion products?
Laravel framework version: 9.41.0
Aimeos Laravel version: * 2022.07.2
PHP Version: 8.1.12
Environment: Linux
I want to show only products that have categories added their promotion categories list.
The file I'm redacting is a customized version of ai-client-html/src/Client/Html/Catalog/Lists/Standard.
I'm changing the filtering inside data() function.
Aimeos Laravel version: * 2022.07.2
PHP Version: 8.1.12
Environment: Linux
I want to show only products that have categories added their promotion categories list.
The file I'm redacting is a customized version of ai-client-html/src/Client/Html/Catalog/Lists/Standard.
I'm changing the filtering inside data() function.
Re: How to filter only promotion products?
You can filter products by category types for the frontend using:
This is a macro overwriting the conditions() method in the \Aimeos\Client\Html\Catalog\Lists\Standard class and adds an additional condition that checks if the product has a list item referencing a category and the list type "promotion".
Code: Select all
\Aimeos\Client\Html\Catalog\Lists\Standard::macro( 'conditions', function( \Aimeos\Controller\Frontend\Product\Iface $cntl, \Aimeos\Base\View\Iface $view ) {
if( $view->config( 'client/html/catalog/instock', false ) ) {
$cntl->compare( '>', 'product.instock', 0 );
}
$cntl->compare( '!=', $cntl->function( 'product:has', ['catalog', 'promotion'] ), null );
} );
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
Re: How to filter only promotion products?
Thank you, this was exactly what I needed for my filtering.aimeos wrote: ↑25 Nov 2022, 14:38Code: Select all
$cntl->compare( '!=', $cntl->function( 'product:has', ['catalog', 'promotion'] ), null );