What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
We are building a B2B shop. For our warehousetool we have to create a XML file when an order is pla
We are building a B2B shop.
For our warehousetool we have to create a XML file when an order is placed. That works well.
Now I have to replace the billing address from the $orderEntity
with the address from the company business unit. How can I achieve that? How to get the address of the company businesst unit from the orderEntity?
Any help is appreciated and code examples would be awesome.
Comments
-
You should add an order-saver plugin (in the checkout module) that persists the relevant business unit information with the sales order. Have a look at
\Pyz\Zed\Checkout\CheckoutDependencyProvider
it contains a lot of plugins already.0 -
I already create the XML with an OMS Plugin.
But I don't know how to get the company business unit address from the orderEntity there.
I have the
companyId
and thecustomerReference
to get the company business unit.I tried
$customer = CustomerReader::findCustomerByReference($orderEntity->getCustomerReference()); $companyBusinessUnitAddress = $customer->getCustomerTransfer()->getCompanyUserTransfer()->getCompanyBusinessUnit()->getAddressCollection()[0]; if($companyBusinessUnitAddress){ $billingAddress = $companyBusinessUnitAddress; }
with no luck getting the address.
0 -
I would not suggest relying on the data still being available in the regular database tables. Everything sales order related should be stored (as a copy) with the sales order. If you need address information of a business unit during order export I would suggest to persist the address in a dedicated tabele (e.g. pyz_sales_order_business_unit_address )
0 -
There is no easy and quick way to get the address of the business unit from the orderEntity?
0 -
Why would there? As fas as I know Spryker discourages accessing data outside the scope of a sales order. A business unit address might change during the transition of a sales order through the state machine. A sales order should always be a snapshop at the time the order was placed. It could cause a lot of confusion for customers if things change after a sales order has been placed.
0 -
The XML file is the snapshot of the order at this moment. Even if the address is changed, the XML file doesn't.
0 -
I see ... 🤔 . This would rule out an order hydrater since that would be executed every time you obtain a sales order. I guess there's no way around a custom query to get to that information
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 73 Spryker News
- 911 Developer Corner
- 771 Spryker Development
- 87 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 25 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 69 Spryker Safari Questions
- 50 Random