1

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" ? enter image description here

2
  • Is any custom extension used product grid for customization purpose? Oct 19, 2016 at 11:57
  • I don't think so
    – Anna
    Oct 19, 2016 at 12:10

1 Answer 1

1

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

1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.