Retrieving order with products
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!
Retrieving order with products
I have a parent site with many sub sites using the ai-sites extension. I have a decorator on jqadm/order/decorators/global that needs to be able to access all the products on an order even if they are attached to different sub-sites.
So when an order is saved on a particular sub-site, the decorator should look at all products from all sites and perform some actions.
To get the order with its associated products I am trying this:
Although this does retrieve an $orderBase object, it doesn't load the products. What am I doing wrong?
So when an order is saved on a particular sub-site, the decorator should look at all products from all sites and perform some actions.
To get the order with its associated products I am trying this:
Code: Select all
$defaultSiteId = '1.';
$context = $this->context();
$item = $this->view()->item;
$context->locale()->setSiteId($defaultSiteId);
$orderBaseManager = \Aimeos\MShop::create( $context, 'order/base' );
$orderBase = $orderBaseManager->get($item->getId(), ['product']);
Re: Retrieving order with products
The domains to retrieve must be:
Code: Select all
$orderBaseManager->get($item->getId(), ['order/base/product']);
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: Retrieving order with products
great, thank you.
That works to retrieve the products, however the code is only retrieving products for the currently selected site. I am setting the locale site id earlier in the code, is there anything else I need to do to set the context to the default site rather than the site currently selected?
That works to retrieve the products, however the code is only retrieving products for the currently selected site. I am setting the locale site id earlier in the code, is there anything else I need to do to set the context to the default site rather than the site currently selected?
Re: Retrieving order with products
If your context locale object is already using the "default" site, it will work as expected but I guess you are in a sub-site and want to get all orders from the "default" site and all it's sub-sites. You have to set a new locale to a cloned context:
This is documented here:
https://aimeos.org/docs/latest/laravel/ ... os-objects
Code: Select all
$manager = \Aimeos\MShop::create( $context, 'locale' );
$context->setLocale( $manager->bootstrap( 'default', '', '' ) );
https://aimeos.org/docs/latest/laravel/ ... 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
Re: Retrieving order with products
That is exactly what I need, thank you