Magento Asked by Ram Pratap Singh Gour on December 12, 2021
I created a custom column “product_name” in sales/order grid,
When I am sorting this column grid showing error:
Item
(MagentoFrameworkViewElementUiComponentDataProviderDocument)
with the same id “146” already exist
My collection code is :
parent::_initSelect();
$joinTable = $this->getTable('mg_dispatch_date');
$joinTable2 =$this->getTable('customer_entity_varchar');
$joinTable3 = $this->getTable('catalog_product_entity_varchar');
$this->getSelect()->join($joinTable . ' as mdd', 'main_table.entity_id = mdd.order_id', array('*'));
$this->getSelect()->join($joinTable2. ' as fn', 'main_table.customer_id = fn.entity_id and fn.attribute_id = 177',array('value'));
$this->getSelect()->join($joinTable3.' as cpev','main_table.entity_id = cpev.entity_id', array('*'));
return $this;
and sales_order_item.xml
code is :
<column name="product_name" class="MagecoderCustomerrefUiComponentListingColumnProductname">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="boolean">false</item>
<item name="sortable" xsi:type="boolean">true</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
<item name="visible" xsi:type="boolean">true</item>
<item name="label" xsi:type="string" translate="true">Product Name</item>
</item>
</argument>
</column>
Please help is anyone have suggestion, Thanks in Advance.
There are not the filters by product attribute_id and store_id in the query. It is the reason for result has several rows for each product.
Also, the order can be contains many products - you can use GROUP_CONCAT for compose all product name in one row for each order.
If you don't want to show all order's products for the order row you can add
$this->getSelect()->group('main_table.entity_id')
;
Answered by sergei.sss on December 12, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP