Question

my category page price sorting is not working well on dev server. i tried to check

Magento\Catalog\Block\Product\ListProduct

public function getLoadedProductCollection()
{
    $collection = $this->_getProductCollection();

    $categoryId = $this->getLayer()->getCurrentCategory()->getId();
    foreach ($collection as $product) {
        $product->setData('category_id', $categoryId);
    }

    die($collection->getSelect()->assemble());

    return $collection;
}

and made sure that i have the pricing filter set in the URL. http://localhost/myshop/us_en/catsample/?product_list_order=price&product_list_dir=desc

on my local. it returns a query

SELECT e.*, 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, IFNULL(review_summary.reviews_count, 0) AS reviews_count, IFNULL(review_summary.rating_summary, 0) AS rating_summary, stock_status_index.stock_status AS is_salable FROM catalog_product_entity AS e INNER JOIN catalog_product_index_price_store AS price_index ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' LEFT JOIN review_entity_summary AS review_summary ON e.entity_id = review_summary.entity_pk_value AND review_summary.store_id = 19 AND review_summary.entity_type = (SELECT review_entity.entity_id FROM review_entity WHERE (entity_code = 'product')) INNER JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id WHERE (price_index.store_id = 19) AND (e.entity_id IN (3192, 1614, 1641, 2741, 2747, 2765, 2766, 3221, 3226, 3227, 3428, 3452, 3454, 3455, 2095, 2096, 3124, 3125, 3284, 3286, 3223, 3449, 1600, 1603)) ORDER BY price_index.min_price = 0, price_index.min_price DESC

but on dev server.

SELECT e.*, 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, IFNULL(review_summary.reviews_count, 0) AS reviews_count, IFNULL(review_summary.rating_summary, 0) AS rating_summary, stock_status_index.stock_status AS is_salable FROM catalog_product_entity AS e INNER JOIN catalog_product_index_price_store AS price_index ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' LEFT JOIN review_entity_summary AS review_summary ON e.entity_id = review_summary.entity_pk_value AND review_summary.store_id = 19 AND review_summary.entity_type = (SELECT review_entity.entity_id FROM review_entity WHERE (entity_code = 'product')) INNER JOIN cataloginventory_stock_status AS stock_status_index ON e.entity_id = stock_status_index.product_id WHERE (price_index.store_id = 19) AND (e.entity_id IN (1516, 1517, 1597, 1600, 1602, 1603, 1605, 1606, 1607, 1610, 1613, 1638, 1639, 1640, 1643, 1645, 1648, 1650, 1654, 1655, 1656, 1657, 1672, 1677, 1697, 1698, 1723, 1726, 1729, 1733, 1736, 1738, 1742, 1800, 1806, 1807, 1831, 1834, 1836, 1888, 1891, 1893, 1910, 1911, 1912, 1948, 1964, 1979, 1996, 1999, 2000, 2023, 2024, 2025, 2028, 2029, 2036, 2040, 2044, 2095, 2096, 2160, 2177, 2253, 2637, 2670, 2736, 2738, 2758, 2773, 2774, 2790, 2791, 2812, 2820, 2821, 2879, 3046, 3047, 3083, 3114, 3124, 3125, 3152, 3154, 3155, 3177, 3178, 3179, 3186, 3187, 3188, 3193, 3222, 3223, 3224, 3248, 3269, 3270, 3275, 3278, 3282, 3284, 3286, 3289, 3306, 3377, 3379, 3380, 3381, 3385, 3386, 3387, 3388, 3389, 3390, 3416, 3418, 3419, 3424, 3437, 3438, 3449, 3529, 3530, 3531, 3535, 3550, 3554, 3555, 3556, 3557, 3558, 3559, 3580, 3582, 3590, 3591, 3592, 2747, 2765, 2766, 3192, 3221, 3226, 3227, 3428, 3452, 3454, 3455, 1641, 1614, 2741)) ORDER BY FIELD(e.entity_id,1516,1517,1597,1600,1602,1603,1605,1606,1607,1610,1613,1638,1639,1640,1643,1645,1648,1650,1654,1655,1656,1657,1672,1677,1697,1698,1723,1726,1729,1733,1736,1738,1742,1800,1806,1807,1831,1834,1836,1888,1891,1893,1910,1911,1912,1948,1964,1979,1996,1999,2000,2023,2024,2025,2028,2029,2036,2040,2044,2095,2096,2160,2177,2253,2637,2670,2736,2738,2758,2773,2774,2790,2791,2812,2820,2821,2879,3046,3047,3083,3114,3124,3125,3152,3154,3155,3177,3178,3179,3186,3187,3188,3193,3222,3223,3224,3248,3269,3270,3275,3278,3282,3284,3286,3289,3306,3377,3379,3380,3381,3385,3386,3387,3388,3389,3390,3416,3418,3419,3424,3437,3438,3449,3529,3530,3531,3535,3550,3554,3555,3556,3557,3558,3559,3580,3582,3590,3591,3592,2747,2765,2766,3192,3221,3226,3227,3428,3452,3454,3455,1641,1614,2741)

im not sure why in dev server. its not being sorted by min_price.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top