-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Issue 31043: Elastic Search interferes with the default sort order of products (changing newest first to oldest first) #36900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rogerdz
wants to merge
8
commits into
magento:2.4-develop
Choose a base branch
from
rogerdz:fix-31043
base: 2.4-develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+103
−2
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
aba5efd
Elastic Search interferes with the default sort order of products (ch…
rogerdz f49e838
Merge branch '2.4-develop' into fix-31043
engcom-Hotel 231cb2a
Merge branch '2.4-develop' into fix-31043
engcom-Dash 11bf44b
Merge branch '2.4-develop' into fix-31043
engcom-Dash 4f3d079
Fixed Functional Failures & added store config for sort Order
engcom-Dash 5ff15c2
Fixed Static Failures
engcom-Dash a8c13d4
Merge branch '2.4-develop' into fix-31043
engcom-Hotel d96183b
Merge branch '2.4-develop' into fix-31043
engcom-Bravo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
app/code/Magento/Catalog/Model/Config/Source/SortOrder.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright 2025 Adobe | ||
* All Rights Reserved. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Catalog Product List Sort Order | ||
* | ||
*/ | ||
namespace Magento\Catalog\Model\Config\Source; | ||
|
||
class SortOrder implements \Magento\Framework\Data\OptionSourceInterface | ||
{ | ||
/** | ||
* Retrieve option values array | ||
* | ||
* @return array | ||
*/ | ||
public function toOptionArray(): array | ||
{ | ||
return [ | ||
['value' => 'ASC', 'label' => __('Ascending')], | ||
['value' => 'DESC', 'label' => __('Descending')], | ||
]; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductSortByPositionInDescOrderTest.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright 2020 Adobe | ||
* All Rights Reserved. | ||
*/ | ||
--> | ||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="StorefrontProductSortByPositionInDescOrderTest"> | ||
<annotations> | ||
<stories value="Sort Products having same position on Storefront In Desc Order"/> | ||
<title value="Sort products with the same position in descending order appropriately"/> | ||
<description value="Use store configuration to sort products of same position in desc order"/> | ||
<severity value="MAJOR"/> | ||
<testCaseId value="AC-14411"/> | ||
<group value="Catalog"/> | ||
</annotations> | ||
<before> | ||
<createData entity="_defaultCategory" stepKey="createCategory"/> | ||
<createData entity="productAlphabeticalA" stepKey="product1"> | ||
<requiredEntity createDataKey="createCategory"/> | ||
</createData> | ||
<createData entity="productAlphabeticalB" stepKey="product2"> | ||
<requiredEntity createDataKey="createCategory"/> | ||
</createData> | ||
<magentoCLI command="config:set {{CustomStoreFrontProductsSortByOrder.path}} {{CustomStoreFrontProductsSortByOrder.value}}" stepKey="setCustomSortByOrderValue"/> | ||
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> | ||
<argument name="indices" value=""/> | ||
</actionGroup> | ||
</before> | ||
<after> | ||
<deleteData stepKey="deleteProduct1" createDataKey="product1"/> | ||
<deleteData stepKey="deleteProduct2" createDataKey="product2"/> | ||
<deleteData stepKey="deleteCategory" createDataKey="createCategory"/> | ||
<magentoCLI command="config:set {{DefaultStoreFrontProductsSortByOrder.path}} {{DefaultStoreFrontProductsSortByOrder.value}}" stepKey="setDefaultSortByOrderValue"/> | ||
</after> | ||
|
||
<actionGroup ref="StorefrontNavigateToCategoryUrlActionGroup" stepKey="NavigateToCategoryPageOnStoreFront"> | ||
<argument name="categoryUrl" value="$$createCategory.custom_attributes[url_key]$$"/> | ||
</actionGroup> | ||
<actionGroup ref="StorefrontQuickSearchCheckProductNameInGridActionGroup" stepKey="assertProduct1Position"> | ||
<argument name="productName" value="$product1.name$"/> | ||
<argument name="index" value="2"/> | ||
</actionGroup> | ||
<actionGroup ref="StorefrontQuickSearchCheckProductNameInGridActionGroup" stepKey="assertProduct2Position"> | ||
<argument name="productName" value="$product2.name$"/> | ||
<argument name="index" value="1"/> | ||
</actionGroup> | ||
</test> | ||
</tests> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion constant usage
Select::SQL_ASC
orCollection::SORT_ORDER_ASC
is more preferable