How to get orders with their 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!
-
- Posts: 86
- Joined: 12 Jan 2019, 15:17
How to get orders with their products
I want to get order with their products and their attribute that customer select .
Please tell me step by step guide to get those details.
Secondly Ordered Product with attributes are not saving that what can be the issue that the customer select some attribute while ordering something my system not showing those attributes in the order details.maybe i have done some thing
Please Guide me for those issue that how i can solve that my system show ordered product with their attribute selected .
Thanks
Please tell me step by step guide to get those details.
Secondly Ordered Product with attributes are not saving that what can be the issue that the customer select some attribute while ordering something my system not showing those attributes in the order details.maybe i have done some thing
Please Guide me for those issue that how i can solve that my system show ordered product with their attribute selected .
Thanks
Re: How to get orders with their products
To get the orders of the current customer:
The API docs describe what you can do with the objects: https://aimeos.org/api/latest/class-Aim ... Iface.html
For adding attributes to the ordered products, they must be either of type "variant", "configurable", "custom" or "hidden". Standard attributes won't be added to ordered products.
Code: Select all
$context = app('\Aimeos\Shop\Base\Context')->get();
$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
$search = $manager->createSearch();
$search->setConditions($search->compare('==', 'order.base.customerid', $context->getUserId()));
// add 'order/base/address', 'order/base/coupon' and/or 'order/base/service' as well if necessary
$orders = $manager->searchItems($search, ['order/base/product']);
foreach($orders as $order) {
foreach($order->getProducts() as $orderProducts) {
foreach($orderProducts->getAttributeItems() as $orderProductAttribute) {
// ...
}
}
}
For adding attributes to the ordered products, they must be either of type "variant", "configurable", "custom" or "hidden". Standard attributes won't be added to ordered products.
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
-
- Posts: 86
- Joined: 12 Jan 2019, 15:17
Re: How to get orders with their products
i have used these types for attributes that i attach with the product
but when user buy product and select some options .butt when order created order did not save those attributes (Options that user select like size or color) are not saving with the order
for reference :
http://prntscr.com/mrusw9
right now i m getting only name of product
http://prntscr.com/mruuge
And kindly tell me from where i can get the order id right after the order process complete so that i can use it for getting those products details.
but when user buy product and select some options .butt when order created order did not save those attributes (Options that user select like size or color) are not saving with the order
for reference :
http://prntscr.com/mrusw9
right now i m getting only name of product
http://prntscr.com/mruuge
And kindly tell me from where i can get the order id right after the order process complete so that i can use it for getting those products details.
Re: How to get orders with their products
Did you add variant attributes of the right type? Please show by screenshot
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
-
- Posts: 86
- Joined: 12 Jan 2019, 15:17
Re: How to get orders with their products
we are adding Article type products right now.
For options( the way we are attaching them with the product) reference:
https://prnt.sc/msvlz5
For options( the way we are attaching them with the product) reference:
https://prnt.sc/msvlz5
-
- Posts: 2
- Joined: 04 Mar 2019, 12:50
Re: How to get orders with their products
awesome this post. cool post
Re: How to get orders with their products
Your configurable products look OK. What Aimeos version are you using?
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
-
- Posts: 86
- Joined: 12 Jan 2019, 15:17
Re: How to get orders with their products
Thanks for your reply sir. Problem was from my side.aimeos wrote:Your configurable products look OK. What Aimeos version are you using?
Re: How to get orders with their products
Hello sir,
This post helps me to get order products.
See my above code. I have added this code in my overridden confirmAction function. It gives me all order details. i need order detail which logged in user created latest order?
This post helps me to get order products.
Code: Select all
$context = App::make('\Aimeos\Shop\Base\Context')->get();
$baseManager = \Aimeos\MShop::create($context, 'order/base');
$search = $baseManager->createSearch();
$items = $baseManager->searchItems($search, ['order/base/product']);
$basket = reset($items);
foreach ($basket->getProducts() as $orderProduct)
{
foreach($orderProduct->getAttributeItems() as $orderProductAttribute) {
dd($orderProductAttribute->getParentId());
}
}
Re: How to get orders with their products
Please do not use this code as is because it returns a more or less random order regardless of who placed it!
Which Aimeos version do you use?
Which Aimeos version do you use?
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