Dalbin Shimy
Dalbin Shimy

Reputation: 53

save value to custom field added to spy_sales_payment table spryker

I have added a custom field called custom_payment_id in spy_sales_payment table,added the field in transfer file too sales_payment.transfer.xml

and added the column using slaes.schema.xml file

How to set value to this field while placing order

Upvotes: 0

Views: 106

Answers (1)

Herbert Scheffknecht
Herbert Scheffknecht

Reputation: 631

A concrete answer is hard, because it depends where you get the data from. Spryker is very flexible and there are many ways to solve that.

I guess you're adding the custom_payment_id during checkout (i.e. in the payment step) to the PaymentTransfer object inside of the QuoteTransfer object. (It's a good idea to extend the PaymentTransfer object as well).

Then \Spryker\Zed\Payment\Business\Order\SalesPaymentSaver::mapSalesPaymentEntity is a good starting point to extend, which hydrates the SpySalesPayment object from the PaymentTransfer object.

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

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

        return $salesPaymentEntity;
    }

Upvotes: 0

Related Questions