How to get customer with orders ?
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
How to get customer with orders ?
Hi community ) Long time with no questions from me ) I have real problem.
I need to get customer with his orders. Exactly would be great to get several customers with their base orders which are paid.
Now it is very ugly in aimeos, or maybe I don't know the right way....
I try to get ids of orders which have payment status "received", then I search the items with "order/base" manager by those ordersIds and ids of customers which I need.. So crazy ( Is there good way for this ?
This is the components versions:
I need to get customer with his orders. Exactly would be great to get several customers with their base orders which are paid.
Now it is very ugly in aimeos, or maybe I don't know the right way....
I try to get ids of orders which have payment status "received", then I search the items with "order/base" manager by those ordersIds and ids of customers which I need.. So crazy ( Is there good way for this ?
This is the components versions:
Code: Select all
aimeos/ai-admin-jqadm 2019.10.6 Aimeos ai-admin-jqadm extension
aimeos/ai-admin-jsonadm 2019.10.2 Aimeos ai-admin-jsonadm extension
aimeos/ai-client-html 2019.10.10 Aimeos ai-client-html extension
aimeos/ai-client-jsonapi 2019.10.2 Aimeos JSON API extension
aimeos/ai-controller-frontend 2019.10.3 Aimeos ai-controller-frontend extension
aimeos/ai-controller-jobs 2019.10.4 Aimeos ai-controller-jobs extension
aimeos/ai-gettext 2019.10.1 Aimeos Gettext extension
aimeos/ai-laravel 2019.10.2 Laravel adapter for Aimeos web shops and e-commerce solutions
aimeos/ai-payments 2019.10.1 Payment extension for Aimeos web shops and e-commerce solutions
aimeos/ai-swiftmailer 2019.10.1 SwiftMailer adapter for Aimeos web shops and e-commerce solutions
aimeos/aimeos-core 2019.10.7 Full-featured e-commerce components for high performance online shops
aimeos/aimeos-laravel 2019.10.1 Professional, full-featured and high performance Laravel e-commerce package for online shops and complex B2B projects
Re: How to get customer with orders ?
Make sure you use the latest 2019.10 release. Then, you can do:
In 2020.x, this will be even simpler:
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'order' );
$search = $manager->createSearch();
$search->setConditions( $search->combine( '&&', [
$search->compare( '==', 'order.statuspayment', 4 ),
$search->compare( '==', 'order.base.customerid', [1, 2, 3] )
] ) );
$orderItems = $manager->searchItems( $search, ['order/base', 'order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service'] );
foreach( $orderItems as $orderItem ) {
$basket = $orderItem->getBaseItem();
$orderProducts = $baset->getProduct();
}
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'order' );
$filter = $manager->filter()->add( ['order.statuspayment' => 4, 'order.base.customerid' => [1, 2, 3]] );
$orderItems = $manager->search( $filter, ['order/base', 'order/base/address', 'order/base/coupon', 'order/base/product', 'order/base/service'] );
foreach( $orderItems->getBaseItem() as $basket ) {
$orderProducts = $baset->getProduct();
}
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: How to get customer with orders ?
Great thank you for the fast support!
But can I also set condition to the query to get orders which have statuspayment = 4 ?
And will your first example work for the following versions ?
And how can I update aimeos components ? Because when I updated it some time I had to change my custom extension's code because behavior of aimeos was changed. This is why I am not harry to update it )
But can I also set condition to the query to get orders which have statuspayment = 4 ?
And will your first example work for the following versions ?
Code: Select all
aimeos/ai-admin-jqadm 2019.10.6 Aimeos ai-admin-jqadm extension
aimeos/ai-admin-jsonadm 2019.10.2 Aimeos ai-admin-jsonadm extension
aimeos/ai-client-html 2019.10.10 Aimeos ai-client-html extension
aimeos/ai-client-jsonapi 2019.10.2 Aimeos JSON API extension
aimeos/ai-controller-frontend 2019.10.3 Aimeos ai-controller-frontend extension
aimeos/ai-controller-jobs 2019.10.4 Aimeos ai-controller-jobs extension
aimeos/ai-gettext 2019.10.1 Aimeos Gettext extension
aimeos/ai-laravel 2019.10.2 Laravel adapter for Aimeos web shops and e-commerce solutions
aimeos/ai-payments 2019.10.1 Payment extension for Aimeos web shops and e-commerce solutions
aimeos/ai-swiftmailer 2019.10.1 SwiftMailer adapter for Aimeos web shops and e-commerce solutions
aimeos/aimeos-core 2019.10.7 Full-featured e-commerce components for high performance online shops
aimeos/aimeos-laravel 2019.10.1 Professional, full-featured and high performance Laravel e-commerce package for online shops and complex B2B projects
Re: How to get customer with orders ?
Updated the original code.
2019.10 is an LTS version with bugfixes only and there are no structural changes any more. Only if you want to update to 2020.x, you have to expect breaking changes.
2019.10 is an LTS version with bugfixes only and there are no structural changes any more. Only if you want to update to 2020.x, you have to expect breaking changes.
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: How to get customer with orders ?
Excellent! Great solution, your code works!
-
- Expert
- Posts: 274
- Joined: 27 Jun 2019, 16:19
Re: How to get customer with orders ?
Ahh sorry, however I have error:
Order does not have getBaseItem method.. So I can't get the base order object ((
This is how order looks like in debug:
So it does not seem like order has base object or any child items...
Is the problem because of my old version ?
Code: Select all
Call to undefined method Aimeos\MShop\Order\Item\Standard::getBaseItem()
This is how order looks like in debug:
Code: Select all
Aimeos\MShop\Order\Item\Standard {#816 ▼
-bdata: array:12 [▼
"order.id" => "45"
"order.baseid" => "45"
"order.siteid" => "1"
"order.type" => "web"
"order.datepayment" => "2020-08-27 15:01:22"
"order.datedelivery" => null
"order.statuspayment" => "6"
"order.statusdelivery" => "-1"
"order.relatedid" => null
"order.ctime" => "2020-08-27 15:01:22"
"order.mtime" => "2020-08-27 18:28:32"
"order.editor" => "email@gmail.com"
]
-prefix: "order."
-available: true
-modified: false
}
Is the problem because of my old version ?
Re: How to get customer with orders ?
Like said, you need to update to the latest 2019.10 release. You are using aimeos/aimeos-core 2019.10.7, latest one is 2019.10.31
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: How to get customer with orders ?
I am sorry, does aimeos have such terminal command to update components ?
Re: How to get customer with orders ?
Simply use
Code: Select all
composer update
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: How to get customer with orders ?
composer update I don't want to use because I don't want to update a lot other packages from vendor. I want only update aimeos to version 2019.10.31 like you said)