magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Order grid with advanced joins #327

Open manuelcanepa opened 3 years ago

manuelcanepa commented 3 years ago

Description

In order to add extra data to the sales_order_grid table, magento provide a way through di.xml extending the virtual type Magento\Sales\Model\ResourceModel\Order\Grid and adding columns or joins. In the joins case, there is no way to chage the main table. If the module has only one table to join with sales_order there is no problem, in case we have a multiple tables related is needed to add every primary key on the sales_order table.

Example

Table zones:

Table prices:

Table delivery_time:

Table zones_matrix:

Table sales_order:

Proposed solution

Change:

                    $this->mainTableName,

with:

                    $data['origin_table'] ?: $this->mainTableName,

This change will allow to use a custom table (that for sure will be joined before) to get others tables not related directly to sales_order.

https://github.com/magento/magento2/blob/28bedc7031ca0eca3d7b4e5830028fa934ed0ac4/app/code/Magento/Sales/Model/ResourceModel/Grid.php#L157

m2-assistant[bot] commented 3 years ago

Hi @manuelcanepa. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this