Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join extension attributes are not added to Order and Order Items #14623

Open
k4emic opened this issue Apr 10, 2018 · 7 comments · May be fixed by #37905
Open

Join extension attributes are not added to Order and Order Items #14623

k4emic opened this issue Apr 10, 2018 · 7 comments · May be fixed by #37905
Assignees
Labels
Area: Order Component: Sales Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@k4emic
Copy link

k4emic commented Apr 10, 2018

Preconditions

  1. Magento 2.1.3
  2. 7.0.25-0ubuntu0.16.04.1

Steps to reproduce

  1. Define a Extension attribute for the relevant interfaces with a join table:
    <extension_attributes for="Magento\Sales\Api\Data\OrderItemInterface">
        <attribute code="some_id" type="string">
            <join reference_table="SOMETABLE" join_on_field="item_id" reference_field="item_id">
                <field>some_id</field>
            </join>
        </attribute>
    </extension_attributes>
    <extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
        <attribute code="some_id" type="string">
            <join reference_table="SOMETABLE" join_on_field="quote_id" reference_field="quote_id">
                <field>some_id</field>
            </join>
        </attribute>
    </extension_attributes>
  1. Make sure there's matching data in the SOMETABLE table and the sales_order_item table
  2. Request order(s) or order items via REST

Expected result

  1. The "some_id" attribute should be included in the response for orders and order items

Actual result

  1. The extension attribute is not included in any of the two responses

This was partially fixed in #8035, but only for order search results

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Apr 10, 2018
@k4emic
Copy link
Author

k4emic commented Apr 10, 2018

I've fixed this (for order items) for my project by adding the following patch to our project, until a permanent solution is found. This will only fix the problem for some requests, but might provide a starting point for someone looking for a better fix.

--- Model/Order.php      2018-04-10 17:03:57.092710675 +0200
+++ Model/Order.php	2018-04-10 17:04:39.608326985 +0200
@@ -266,6 +266,10 @@
      * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
      */
     protected $timezone;
+    /**
+     * @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
+     */
+    private $joinProcessor;

     /**
      * @param \Magento\Framework\Model\Context $context
@@ -322,6 +326,7 @@
         \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $salesOrderCollectionFactory,
         PriceCurrencyInterface $priceCurrency,
         \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productListFactory,
+        \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor,
         \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
         \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
         array $data = []
@@ -346,6 +351,7 @@
         $this->_trackCollectionFactory = $trackCollectionFactory;
         $this->salesOrderCollectionFactory = $salesOrderCollectionFactory;
         $this->priceCurrency = $priceCurrency;
+        $this->joinProcessor = $joinProcessor;
         parent::__construct(
             $context,
             $registry,
@@ -1248,6 +1254,7 @@
     public function getItemsCollection($filterByTypes = [], $nonChildrenOnly = false)
     {
         $collection = $this->_orderItemCollectionFactory->create()->setOrderFilter($this);
+        $this->joinProcessor->process($collection);

         if ($filterByTypes) {
             $collection->filterByTypes($filterByTypes);

@ghost ghost self-assigned this Jul 20, 2018
@ghost ghost added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Component: Sales Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Jul 20, 2018
@ghost
Copy link

ghost commented Jul 23, 2018

Hi @k4emic , thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost removed their assignment Jul 23, 2018
@magento-engcom-team magento-engcom-team removed the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jul 29, 2018
@k4emic k4emic added the Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release label Aug 30, 2018
@ghost ghost removed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Nov 6, 2020
@magento-engcom-team magento-engcom-team added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Nov 30, 2020
@engcom-Lima engcom-Lima added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 25, 2021
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-996 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Aug 25, 2021

✅ Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@Kiraberos
Copy link
Contributor

@magento I am working on this

Kiraberos added a commit to Kiraberos/magento2 that referenced this issue Mar 28, 2023
…rder Items

- fixed issue associated with joining extension attributes for Order and Order items
Kiraberos added a commit to Kiraberos/magento2 that referenced this issue Apr 11, 2023
…rder Items

- completed the implementation of tests
@Vasudev-22
Copy link
Contributor

@magento I am working on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Order Component: Sales Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Pull Request In Progress
7 participants