【问题标题】:save value to custom field added to spy_sales_payment table spryker将值保存到添加到 spy_sales_payment 表 spryker 的自定义字段
【发布时间】:2023-02-08 04:44:15
【问题描述】:

我在 spy_sales_payment 表中添加了一个名为 custom_payment_id 的自定义字段,也在传输文件中添加了该字段 sales_payment.transfer.xml

并使用 slaes.schema.xml 文件添加了列

如何在下订单时为该字段设置值

【问题讨论】:

  • 取决于您的实施。通常映射是在您的业务或持久层中完成的。没有代码很难分辨,但如果你的传输字段名称与数据库字段名称匹配,你可能很幸运并且什么都不用做,因为传输/实体是使用 fromArray/toArray 相互转换的

标签: spryker


【解决方案1】:

很难给出具体的答案,因为这取决于您从何处获取数据。 Spryker 非常灵活,有很多方法可以解决这个问题。

我猜您是在结帐期间(即在付款步骤中)将 custom_payment_id 添加到 QuoteTransfer 对象内的 PaymentTransfer 对象。 (扩展 PaymentTransfer 对象也是一个好主意)。

然后 SprykerZedPaymentBusinessOrderSalesPaymentSaver::mapSalesPaymentEntity 是一个很好的扩展起点,它从 PaymentTransfer 对象中合成 SpySalesPayment 对象。

    protected function mapSalesPaymentEntity(PaymentTransfer $paymentTransfer, $idSalesOrder)
    {
        $paymentMethodTypeEntity = parent::mapSalesPaymentEntity($paymentTransfer, $idSalesOrder);

        $salesPaymentEntity->setCustomPaymentId($paymentTransfer->getCustomPaymentId());

        return $salesPaymentEntity;
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 1970-01-01
    • 2022-01-25
    • 2013-10-19
    相关资源
    最近更新 更多