Skip to content

Copying custom fields from quote to order table using sales_convert_quote in fieldset.xml #5823

Closed
@srenon

Description

@srenon

Preconditions

  1. Magento 2.1

Steps to reproduce

  1. Create a custom module that add a field to quote and sales_order table
  2. Update the field in quote table and then place an order

Expected result

  1. The field value will get copied to the order table

Actual result

  1. The field does not get copy over to sales_order table

The issue seem to be cause by :
/vendor/magento/framework/Api/DataObjectHelper.php

Line 238

$secondObjectArray = $this->objectProcessor->buildOutputDataArray($secondDataObject, $interfaceName);
$this->_setDataValues($firstDataObject, $secondObjectArray, $interfaceName);
return $this;

vendor/magento/framework/Reflection/DataObjectProcessor.php

Line 75

    public function buildOutputDataArray($dataObject, $dataObjectType)
    {
        $methods = $this->methodsMapProcessor->getMethodsMap($dataObjectType);
        $outputData = [];

        /** @var MethodReflection $method */
        foreach (array_keys($methods) as $methodName) {
            if (!$this->methodsMapProcessor->isMethodValidForDataField($dataObjectType, $methodName)) {
                continue;
            }

Since the method for the newly added db field is not defined in "\Magento\Sales\Api\Data\OrderInterface" it will not get copied in to "$secondObjectArray" therefore it will not get set in "$this->_setDataValues()"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: SalesIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedRelease Line: 2.1Reproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasenon-issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions