Skip to content

Different default direction in sorting for category page or catalog search #39545

Open
@venchiarutti

Description

Preconditions and environment

  • All versions

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

/**

  • Default direction
  • @var string
    */
    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

  1. Sort by something in the catalog search
  2. Sort by something in the category page
  3. See that the direction is inverted

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

  • 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”.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Ready for Confirmation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions