Different default direction in sorting for category page or catalog search #39545
Labels
Issue: ready for confirmation
Reported on 2.4.x
Indicates original Magento version for the Issue report.
Preconditions and environment
The category page default direction is defined by
When it is a catalog search magento 2 uses the value from this piece of code in the file: vendor/magento/module-catalog-search/Block/Result.php
public function setListOrders()
{
$category = $this->catalogLayer->getCurrentCategory();
/* @var $category \Magento\Catalog\Model\Category */
$availableOrders = $category->getAvailableSortByOptions();
unset($availableOrders['position']);
$availableOrders['relevance'] = __('Relevance');
$this->getListBlock()->setAvailableOrders(
$availableOrders
)->setDefaultDirection(
'desc'
)->setDefaultSortBy(
'relevance'
);
return $this;
}
But when it is in the category page it uses the value from vendor/magento/module-catalog/Block/Product/ProductList/Toolbar.php
/**
*/
protected $_direction = ProductList::DEFAULT_SORT_DIRECTION;
So it has a different default order depending on where...
The correct for such important feature should have configuration for both cases in the admin, but having a different default direction with the same toolbar understanding both as the default one is causing issues
Steps to reproduce
This can be more clearly checked by for example adding an eav_attribute to be used as sort option, in the catalog it will be in a direction and in category another one
Expected result
The correct would be having configurations for both cases
Actual result
Different sorting direction in catalog search and category page
Additional information
No response
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: