我正在使用带有令牌身份验证的 REST API 将数据从 M1 导出到全新安装的 M2.2.0 安装。
一切都适用于客户和产品,但我无法理解如何在不创建购物车的情况下创建订单。
我的意思是,我已经从订单中获得了所有需要的数据,之前应该不需要创建购物车,正如我找到的所有解决方案中所建议的那样(也在官方 magento指南中)。
我在上述指南中遵循相同的步骤,但尝试发布有关订单的数据,我不断收到错误消息:
"Fatal Error: 'Uncaught Error: Call to a member function getMethodInstance() on null in \/var\/www\/html\/app\/code\/Magento\/Payment\/Observer\/SalesOrderBeforeSaveObserver.php:24\nStack trace:\n#0 \/var\/www\/html\/lib\/internal\/Magento\/Framework\/Event\/Invoker\/InvokerDefault.php(72): Magento\\Payment\\Observer\\SalesOrderBeforeSaveObserver->execute(Object(Magento\\Framework\\Event\\Observer))\n#1 \/var\/www\/html\/lib\/internal\/Magento\/Framework\/Event\/Invoker\/InvokerDefault.php(60): Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod(Object(Magento\\Payment\\Observer\\SalesOrderBeforeSaveObserver), Object(Magento\\Framework\\Event\\Observer))\n#2 \/var\/www\/html\/lib\/internal\/Magento\/Framework\/Event\/Manager.php(66): Magento\\Framework\\Event\\Invoker\\InvokerDefault->dispatch(Array, Object(Magento\\Framework\\Event\\Observer))\n#3 \/var\/www\/html\/generated\/code\/Magento\/Framework\/Event\/Manager\/Proxy.php(95): Magento\\Framework\\Event\\Manager->dispatch('sales_order_sav...', Array)\n#4 \/var\/www\/html\/lib\/internal\/Magento\/Framework\/Model\/AbstractModel.php(694):' in '\/var\/www\/html\/app\/code\/Magento\/Payment\/Observer\/SalesOrderBeforeSaveObserver.php' on line 24"
这是我用来尝试的示例 JSON:
{
"entity": {
"customer_email": "provacustomer@mail.com",
"customer_firstname": "mario",
"customer_lastname": "rossi",
"base_grand_total": 120,
"discount_amount": 0,
"grand_total": 120,
"increment_id": "200001414155",
"shipping_amount": 7,
"status": "processing",
"store_id": 1,
"subtotal": 100,
"tax_amount": 20,
"items": {
"description": "prodotto mio",
"item_id": 3,
"price": 10,
"product_id": 3,
"product_type": "simple",
"qty_ordered": 2,
"sku": "002",
"tax_amount": 2,
"weight": 1
}
},
"billing_address": {
"firstname": "giuseppa",
"lastname": "rossi",
"company": "mycompany",
"city": "rome",
"region": "california",
"region_id": 12,
"postcode": "12312",
"telephone": "1234556677",
"country_id": "US",
"street": ["via prima", "via seconda"]
},
"payment": {
"amount_paid": 120,
"method": "checkmo"
},
"status_histories": [{
"comment": "new order",
"status": "processing"
}],
"extension_attributes": {
"shipping_assignments": [{
"shipping": {
"address": [{
"firstname": "franca",
"lastname": "vardididi",
"company": "mycompany",
"city": "rome",
"region": "california",
"region_id": 12,
"postcode": "12312",
"telephone": "1234556677",
"country_id": "US",
"street": ["via prima", "via seconda"]
}],
"method": "checkmo",
"total": {
"base_shipping_amount": 7
}
},
"items": [{
"description": "prodotto mio",
"item_id": 3,
"price": 10,
"product_id": 3,
"product_type": "simple",
"qty_ordered": 2,
"sku": "002",
"tax_amount": 2,
"weight": 1
}]
}]
}
}
编辑
在这个问题中使用 json我设法创建了订单。