Get all products - except those with parents
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Get all products - except those with parents
I would like to receive all products that are not assigned to a parent product. With
I get all products with type "select" (all parent products). But how can I retrieve also those products with type "default" who dont have a parent product.
In the end, I need all the products that are displayed in the list by default.
Thanks for a tip.
===
TYPO3 9.5.x
PHP 7.2
Aimeos 20.7.1
Code: Select all
$manager = \Aimeos\MShop::create($context, 'product');
$search = $manager->createSearch();
$expr = $search->compare('==', 'product.type', 'select');
$search->setConditions($expr);
$items = $manager->searchItems( $search );
In the end, I need all the products that are displayed in the list by default.
Thanks for a tip.
===
TYPO3 9.5.x
PHP 7.2
Aimeos 20.7.1
Re: Get all products - except those with parents
It's possible but usually you want all products that are at least in one category (default and selection products):
Code: Select all
$manager = \Aimeos\MShop::create($context, 'index');
$search = $manager->createSearch(true);
$expr = [
$search->compare('!=', 'index.catalog.id', null),
$search->getConditions()
];
$search->setConditions($search->combine( '&&', $expr));
$items = $manager->searchItems( $search );
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: Get all products - except those with parents
Thank you very much. This is exactly what I was looking for.
- parmonov98
- Posts: 33
- Joined: 24 Sep 2020, 12:12
Re: Get all products - except those with parents
What is context var here?aimeos wrote: ↑23 Sep 2020, 14:46 It's possible but usually you want all products that are at least in one category (default and selection products):Code: Select all
$manager = \Aimeos\MShop::create($context, 'index'); $search = $manager->createSearch(true); $expr = [ $search->compare('!=', 'index.catalog.id', null), $search->getConditions() ]; $search->setConditions($search->combine( '&&', $expr)); $items = $manager->searchItems( $search );
How to and what to assign to it?
Re: Get all products - except those with parents
It's the central dependency container. How to retrieve it depends on your environment:
- Laravel: https://aimeos.org/docs/latest/laravel/ ... os-objects
- Symfony: https://aimeos.org/docs/latest/symfony/ ... os-objects
- TYPO3: https://aimeos.org/docs/latest/typo3/ex ... os-objects
- Laravel: https://aimeos.org/docs/latest/laravel/ ... os-objects
- Symfony: https://aimeos.org/docs/latest/symfony/ ... os-objects
- TYPO3: https://aimeos.org/docs/latest/typo3/ex ... os-objects
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