Skip to content

Magento\Tax\Model\Quote\ToOrderConverter uses wrong type for extension attribute #6092

Open
@fooman

Description

@fooman

Preconditions (*)

  1. Magento 2.4-develop

Steps to reproduce (*)

  1. Look at code
    https://github.com/magento/magento2/blob/2.1/app/code/Magento/Tax/Model/Quote/ToOrderConverter.php

    $itemAppliedTaxesModified = [];
    if (!empty($itemAppliedTaxes)) {
        foreach ($itemAppliedTaxes as $key => $itemAppliedTaxItem) {
            if (is_array($itemAppliedTaxItem) && !empty($itemAppliedTaxItem)) {
                foreach ($itemAppliedTaxItem as $itemAppliedTax) {
                    $itemAppliedTaxesModified[$key]['type'] = $itemAppliedTax['item_type'];
                    $itemAppliedTaxesModified[$key]['item_id'] = $itemAppliedTax['item_id'];
                    $itemAppliedTaxesModified[$key]['associated_item_id'] = $itemAppliedTax['associated_item_id'];
                    $itemAppliedTax['extension_attributes']['rates'] = $itemAppliedTax['rates'];
                    unset($itemAppliedTax['rates']);
                    $itemAppliedTaxesModified[$key]['applied_taxes'][] = $itemAppliedTax;
                }
            }
        }
        $extensionAttributes->setItemAppliedTaxes($itemAppliedTaxesModified);
    

vs

https://github.com/magento/magento2/blob/2.1/app/code/Magento/Tax/etc/extension_attributes.xml#L14

<extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
    <attribute code="applied_taxes" type="Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface[]" />

resulting in Magento\Sales\Api\Data\OrderExtensionInterface (in generated folder)

/**
 * @return \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface[]|null
 */
public function getItemAppliedTaxes();

/**
 * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface[] $itemAppliedTaxes
 * @return $this
 */
public function setItemAppliedTaxes($itemAppliedTaxes);

Expected result (*)

  1. ExtensionAttributes should be used with the defined interface: array of Magento\Tax\Api\Data\OrderTaxDetailsItemInterface
  2. A developer can trust the stated defined return value

Actual result (*)

  1. a standard php array is used

Metadata

Metadata

Assignees

Labels

Area: TaxComponent: Framework/CodeComponent: TaxIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: dev in progressReproduced 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 releaseReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itbug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions