I have a problem with the default Magento core function. I really don't know whether it is a conflict with any other modules.
When we go to the customer menu in admin and select any customer from the list then click on the order tab in the customer details page. I can see that the loading image is rotating, there is no customer order I can see.
I have checked in the console there is a 500 internal server error. I have go to the class file path(vendor/magento/module-customer/Block/Adminhtml/Edit/Tab/Orders.php) and echo the SQL query.
SELECT DISTINCT `main_table`.`entity_id`, `main_table`.`increment_id`, `main_table`.`customer_id`, `main_table`.`created_at`,
`main_table`.`grand_total`, `main_table`.`order_currency_code`, `main_table`.`store_id`, `main_table`.`billing_name`,
`main_table`.`shipping_name`, `sales_order`.`coupon_code`,
group_concat(DISTINCT `sales_order_item`.sku SEPARATOR ", ") AS `sku`,
group_concat(DISTINCT `sales_order_item`.name SEPARATOR ",\n") AS `name`,
group_concat(DISTINCT `sales_order_item`.product_options SEPARATOR "|| ") AS `product_options`,
`sales_order_item`.`qty_ordered`, `sales_order_item`.`qty_invoiced`, `sales_order_item`.`qty_shipped`, `sales_order_item`.`qty_canceled`,
`sales_order_item`.`qty_refunded`
FROM `sales_order_grid` AS `main_table`
LEFT JOIN `sales_order` ON main_table.entity_id = sales_order.entity_id
INNER JOIN `sales_order_item` ON main_table.entity_id = sales_order_item.order_id WHERE (`customer_id` = '73922')
GROUP BY `main_table`.`entity_id`
The error code appears on PHPMyAdmin when I run the code
Error in the query (1052): Column 'customer_id' in where clause is ambiguous
This is the right SQL Query
SELECT DISTINCT `main_table`.*, `sales_order`.`coupon_code`,
group_concat(DISTINCT `sales_order_item`.sku SEPARATOR ", ") AS `sku`,
group_concat(DISTINCT `sales_order_item`.name SEPARATOR ",\n") AS `name`,
group_concat(DISTINCT `sales_order_item`.product_options SEPARATOR "|| ") AS `product_options`,
`sales_order_item`.`qty_ordered`, `sales_order_item`.`qty_invoiced`, `sales_order_item`.`qty_shipped`,
`sales_order_item`.`qty_canceled`, `sales_order_item`.`qty_refunded`
FROM `sales_order_grid` AS `main_table`
LEFT JOIN `sales_order` ON main_table.entity_id = sales_order.entity_id
INNER JOIN `sales_order_item` ON main_table.entity_id = sales_order_item.order_id
WHERE (`main_table`.`customer_id` = '73922')
GROUP BY `main_table`.`entity_id`, `sales_order_item`.`qty_ordered`, `sales_order_item`.`qty_invoiced`, `sales_order_item`.`qty_shipped`,
`sales_order_item`.`qty_canceled`, `sales_order_item`.`qty_refunded`
How can I convert the order.php query to this one?
collection
file. let me know if you did. we can work on separate module for that