Get refItems by condition
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!
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Get refItems by condition
As we now entities in aimeos may have referenced children entities. For example product may have several prices in array. Child objects associated to parent by list table. So when we getRefItems for some entity script firstly getListItems and populates the array of $item->getRegItem()
So tell me please if it possible to get refItemsBy condition ? If not possible which way I need to make it, filter them on DB level, or still retrive all and filter them on array point ?
So tell me please if it possible to get refItemsBy condition ? If not possible which way I need to make it, filter them on DB level, or still retrive all and filter them on array point ?
Re: Get refItems by condition
Can you post some example code you would like to do? We don't understand what you want to achieve based on your explanation.
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
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: Get refItems by condition
Ok, sorry for unclear explanation(
I have a product item \Aimeos\MShop\Product\Item\Standard object,
Then I get product prices
It will return me an array of the objects from mshop_price table. But I don't want to get all prices, I need to get prices by specific condition, for example where quantity = 4 or another condition.
Thank you a lot for the fast answer and help!
I have a product item \Aimeos\MShop\Product\Item\Standard object,
Then I get product prices
Code: Select all
$product->getRefItems('price')
It will return me an array of the objects from mshop_price table. But I don't want to get all prices, I need to get prices by specific condition, for example where quantity = 4 or another condition.
Thank you a lot for the fast answer and help!
Re: Get refItems by condition
You can only limit the referenced items by type and their list type, e.g.
The price items are fetched nevertheless but only the prices with the matching type and list type are returned.
In searchItems() you can limit fetching items by list type:
The currently matching price is determined by getLowestPrice() of the price manager:
See https://github.com/aimeos/aimeos-core/b ... ce.php#L31
Code: Select all
$prices = $item->getRefItems( 'price', '<type>', '<list type>' );
In searchItems() you can limit fetching items by list type:
Code: Select all
$manager->searchItems( $filter, ['price' => ['default']] );
Code: Select all
$priceManager->getLowestPrice( $prices, $quantity );
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