如何通过API在Shopware 6中创建订单

如何解决如何通过API在Shopware 6中创建订单

我正在将商店从旧平台迁移到Shopware6。我需要转移订单,但这样做有困难。我正在使用可以访问旧平台数据库的脚本所调用的API。我已经使用API​​推送了几乎所有其他实体(客户,产品,媒体,类别,它们之间的链接),并且效果很好。 在文档中,似乎应该首先创建一个购物车,然后通过一个操作将其创建为订单,然后添加订单地址,付款并通过操作将状态转换为所需状态。

没有确切的指导,所以我最终尝试将带有订单数据的POST请求推送到order端点,如下所示:

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"
  ]
]

这会在数据库中创建一个订单,但是我无法在admin(admin#/sw/order/index)的订单列表中看到它-实际上,当我尝试更改列表页面时,它破坏了列表。如果我打开另一个订单,然后用我创建的订单ID替换订单ID,则可以打开它,但它没有详细信息框。我只能看到项目,状态和文档。我怀疑这是由于没有链接的付款和货运信息,因此我也通过API在order_address实体中添加了实体,然后尝试创建order_delivery,因此我有货运状态。不幸的是,当我尝试创建具有状态的实体时,我得到了这个信息:

    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"
      }
    }

我被困住了。我需要帮助。我可以在请求中添加一些开关以强制向system字段中写入(创建具有stateId范围的令牌吗?)吗?还是我应该采取行动?但是再说一次,如果没有将order_delivery实体设置为值open ...

,我将无法执行操作

我反正正确吗?通过尝试直接创建实体(这些订单仅作为存档,它们已经全部完成)了?

解决方法

也许您应该将Shopware的迁移插件用于sw5和sw6。 它们在Migration process中进行了描述。 您可以在GitHub上找到这些插件 https://github.com/shopware/SwagMigrationAssistanthttps://github.com/shopware/SwagMigrationConnector

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-