I am migrating a shop form an old platform to Shopware 6. I need to move over orders and I am having problems doing so. I am using the API that is being called by a script that has access to the old platform database. I have already pushed nearly all other entities (customers, products, media, categories, links between those) using the API and it works fine. In the documentation it seems one should create a cart first and then via an action create it into an order, then add order address, payment and transition the states via actions to what is required.
There is no exact guide for it so I ended up trying to push a POST request with order data toorder
endpoint like that:
array:12 [
"orderNumber" => "100000546"
"price" => array:6 [
"netPrice" => 47.3519
"totalPrice" => 50.32
"positionPrice" => 50.32
"calculatedTaxes" => array:1 [
0 => array:3 [
"tax" => 3.314633
"taxRate" => 7
"price" => 50.32
]
]
"taxRules" => array:1 [
0 => array:2 [
"taxRate" => 7
"percentage" => 100
]
]
"taxStatus" => "gross"
]
"shippingCosts" => array:5 [
"unitPrice" => 4.95
"totalPrice" => 4.95
"quantity" => 1
"calculatedTaxes" => array:1 [
0 => array:3 [
"tax" => 0.3465
"taxRate" => 7
"price" => 4.95
]
]
"taxRules" => array:1 [
0 => array:2 [
"taxRate" => 7
"percentage" => 100
]
]
]
"billingAddressId" => "9f27c3c98dfe4e47ad2a9493da5807bc"
"currencyId" => "b7d2554b0ce847cd82f3ac9bd1c0dfca"
"languageId" => "2fbb5fe2e29a4d70aa5854ce7ce3e20b"
"salesChannelId" => "d1d7fc6faedb4600afd0cfe68f627f6d"
"orderDateTime" => "2014-11-03 08:27:43"
"currencyFactor" => 1
"stateId" => "8089405ce1e046f1819823d847125d25"
"lineItems" => array:1 [
0 => array:6 [
"identifier" => "5158757ba32b489faf70fcd7c4578604"
"productId" => "5158757ba32b489faf70fcd7c4578604"
"quantity" => 10
"label" => "Some product"
"position" => 1
"price" => array:5 [
"unitPrice" => 3.64
"totalPrice" => 36.3551
"quantity" => 10
"calculatedTaxes" => array:1 [
0 => array:3 [
"tax" => 0.2548
"taxRate" => 7
"price" => 36.3551
]
]
"taxRules" => array:1 [
0 => array:2 [
"taxRate" => 7
"percentage" => 100
]
]
]
]
]
"orderCustomer" => array:6 [
"customerId" => "cafedb542f2f488e99375192092c9032"
"salutationId" => "08f9cf197c0643ac98590948cf5dd9f8"
"firstName" => "xx
"lastName" => "xx
"email" => "xx
"customerNumber" => "10020"
]
]
This creates an order in the database but I cannot see it in the orders listing in admin (admin#/sw/order/index
) - in fact it breaks the list when I try to change list page. If I open another order and then replace the order id with the one I created I can open it but it does not have the details box. I can see only Items, Status and Documents. I suspected that it is due to the fact that there is no payment and shipment information linked so I added in alsoorder_address
entity via the API and then tried to createorder_delivery
so I have state for the shipment. Unfortunately I get this when I try to create such entity with a state:
0 => {#8643
+"code": "FRAMEWORK__WRITE_CONSTRAINT_VIOLATION"
+"status": "400"
+"detail": "This field is write-protected. (Got: "crud" scope and "system" is required)"
+"template": "This field is write-protected. (Got: "%s" scope and "%s" is required)"
+"meta": {#8655
+"parameters": array:2 [
0 => "crud"
1 => "system"
]
}
+"source": {#8664
+"pointer": "/0/stateIdstateId"
}
}
And I am stuck. I need help. Can I add some switch to the request to force write (create a token withsystem
scope?) into thestateId
field? Or I should perform action? But then again I cannot perform an action without havingorder_delivery
entity already set with valueopen
...
Am I doing it right anyways? By trying to create entities directly (these orders serve just as an archive, they are all completed already)?
Maybe you should use migration plugins from Shopware for sw5 & sw6. They are described there Migration process. And you can find those plugins on GitHub https://github.com/shopware/SwagMigrationAssistant & https://github.com/shopware/SwagMigrationConnector
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.