This is screen from my admin products grid, here I sorting by price column(low to high), but as you can see it's not working right.
Can it be because some products are "downloadable" ?
-
Is any custom extension used product grid for customization purpose?– Dhiren VasoyaOct 19, 2016 at 11:57
-
I don't think so– AnnaOct 19, 2016 at 12:10
1 Answer
I explored what sql query magento created for this sorting grid
SELECT `e`.*, `at_qty`.`qty`, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`
FROM `catalog_product_entity` AS `e`
LEFT JOIN `cataloginventory_stock_item` AS `at_qty` ON (at_qty.`product_id`=e.entity_id) AND (at_qty.stock_id=1)
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0 ORDER BY `price_index`.`min_price` ASC
The interesting part is that it sorting by price_index
.min_price
So for configurable or downloadable products it will take min price of their childen
-
and because of this i am getting wrong product total when sorting by price. Happen on magento 2.1 and seems to be fixed in 2.2. May 2, 2019 at 8:16