Description
Preconditions (*)
- Magento 2.4-develop
- 2.3.5-p1 is all I have tested this in so far.
Steps to reproduce (*)
-
Create a category in Magento with several products in it, all have the position in the category set to the value 1
-
Go to category page
Expected result (*)
- The newest products in the database (the one with the highest entity_id) are shown first
- The Order by for the SQL query for retrieving the products
SELECT `e`.*, `cat_index`.`position` AS `cat_index_position`, `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`
INNER JOIN `catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id=33
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.customer_group_id = 0 AND price_index.website_id = '1' ORDER BY `cat_index`.`position` asc, `e`.`entity_id` DESC
Actual result (*)
- The oldest products(with the lower entity_id) are shown first
- The Order by for the SQL query for retrieving the products
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` 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 = 1 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 AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1 WHERE (stock_status_index.stock_status = 1) AND (e.entity_id IN (1201, 1202, 1203)) ORDER BY FIELD(e.entity_id,1201,1202,1203)
Search Engine=MySQL
the newest product in the database (the one with the highest entity_id) was shown first. With Magento 2.4-develop with Search Engine= Elasticsearch 7
this behaviour changed. The oldest product is shown first, the newest last.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
The severity of this issue will differ between niches but for some businesses, this is quite critical. Like designer or boutique fashion retailers where the target audience frequent the website to view the latest items to hit the fashion lines etc.
I can't believe there are not more reports of this... I did ask the question on Magento Stack Exchange and it is passed by will hardly any views and zero interaction.
I'm obviously assuming this is a bug and not meant to happen.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Activity
m2-assistant commentedon Nov 24, 2020
Hi @zigojacko. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x releaseFor more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue:
@magento I am working on this
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
m2-assistant commentedon Jan 29, 2021
Hi @engcom-Alfa. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇
1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears.2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself.3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.- If the issue is reproducible on
2.4-develop
branch, please, add the labelReproduced on 2.4.x
.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
5. Add label
Issue: Confirmed
once verification is complete.6. Make sure that automatic system confirms that report has been added to the backlog.
m2-assistant commentedon Feb 3, 2021
Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇
1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears.2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself.3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.- If the issue is reproducible on
2.4-develop
branch, please, add the labelReproduced on 2.4.x
.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
5. Add label
Issue: Confirmed
once verification is complete.6. Make sure that automatic system confirms that report has been added to the backlog.
engcom-Delta commentedon Feb 3, 2021
Hi @zigojacko thank you for your report, I'm not able to reproduce issue by steps you described on clean 2.4-develop with elasticsearch
Manual testing scenario:
Result:
✔️ Products is sorted by price on category page
Result:
✔️ Products is sorted by product name on category page
Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest
2.4-develop
branch.zigojacko commentedon Feb 3, 2021
@engcom-Delta you haven't understood the problem and don't show the testing of it.
This has been confirmed in a fresh install of Magento 2 and the problem is apparent.
It is also reported across the other web by other users.
The issue is not that sorting by attribute is not working at all. It is that the default sorting is reversed. So by default, sort order will be in the order that the products have been added (newest first) providing custom sort position not set in category.
Your test doesn't show this at all.
Please can you re-open and test for the actual issue?
zigojacko commentedon Feb 3, 2021
As an example, see this demo store.
In this category, I just added a new product and set the same 'Position' for the product as all the others ('1').
You will see the product is at the end of the list. Even though it is newer than all the others.
If I then switch Elastic Search off and revert to the default MySQL, the newest product will switch to first in the list (as will the entire product listing reverse).
This is the problem @engcom-Delta
Please could someone re-open this issue?
31 remaining items
jigneshc3 commentedon May 5, 2023
The issue is still there. We have a site on Magento 2.4.5-p1 and we can still reproduce the issue. Its strange that after these many years, there is no proper solution found.
I already tried solutions give on #34502 and #32522 . Still no luck.
@zigojacko were you able to find solution yet? Would be great if you can share. Thanks.
Ahmet-Djedovic commentedon May 7, 2023
@jigneshc3 i have implemented a fix for my situation
Model:
MODULE_DIR/Model/CatalogSearch/ResourceModel/Fulltext
`<?php
namespace Ahmet\SortOrderAddon\Model\CatalogSearch\ResourceModel\Fulltext;
use Magento\Framework\App\ObjectManager;
class Collection extends \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection
{
protected function _renderFiltersBefore()
{
/**
* @var \Magento\Framework\App\RequestInterface $request
*/
if (isset($_SERVER['REQUEST_URI']) && !stristr($_SERVER['REQUEST_URI'], "catalogsearch")) {
$request = ObjectManager::getInstance()->create("\Magento\Framework\App\RequestInterface");
$attribute = $request->getParam("product_list_order", "position");
$direction = $request->getParam("product_list_dir", "asc");
if ($direction == 'asc') {
$this->addAttributeToSort($attribute, \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
} elseif ($direction == 'desc') {
$this->addAttributeToSort($attribute, \Magento\Framework\Data\Collection::SORT_ORDER_DESC);
}
}
}`
di.xml
`
`
engcom-Bravo commentedon Apr 9, 2025
Hi @zigojacko,
Thanks for your reporting and collaboration.
We have tried to reproduce the issue in latest 2.4-develop instance and the issue is still reproducible.kindly refer the screenshots.
The oldest products(with the lower entity_id) are shown first.Hence confirming the issue.
Thanks.
github-jira-sync-bot commentedon Apr 9, 2025
✅ Jira issue https://jira.corp.adobe.com/browse/AC-14411 is successfully created for this GitHub issue.
m2-assistant commentedon Apr 9, 2025
✅ Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.