magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

Setting default sort order to descending in categories prevents user from changing sorting direction #39350

Closed ioweb-gr closed 1 week ago

ioweb-gr commented 2 weeks ago

Summary

After upgrading to 2.4.7 we lost the ability to change the default sort order of products in the catalog to descending

To reproduce

  1. Add a catalog_category_view.xml to change default sorting direction to descending
  2. The page loads the products in descending order.
  3. Try to change direction by clicking on the arrow
  4. The direction stays the same instead of changing

https://github.com/user-attachments/assets/4eb77b0c-6bbb-4ee5-8ad1-7512fe4163b3

Examples

Previously this snippet would correctly set the default direction in 2.4.6 but in 2.4.7 it prevents changing the direction

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- set sort direction to descending -->
        <referenceBlock name="product_list_toolbar">
            <action method="setDefaultDirection">
                <argument name="dir" xsi:type="string">desc</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Proposed solution

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 weeks ago

Hi @ioweb-gr. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.

ioweb-gr commented 2 weeks ago

I wanted to add that even changing \Magento\Catalog\Helper\Product\ProductList::DEFAULT_SORT_DIRECTION to "desc" doesn't work for me. Direction changes, but the user is unable to change it back to any other option

engcom-Hotel commented 1 week ago

Hello @ioweb-gr,

Thanks for the report and collaboration!

We have tried to reproduce the issue by upgrading the Magento instance from 2.4.6 to 2.4.7-p3 but the issue is not reproducible for us. Refer to the below screenshots below:

Magento Instance 2.4.6 Dashboard-246

Category Default Sorting as Descending Category-246-desc

After upgrading to 2.4.7-p3

Category Default Sorting as Descending image

Code from catalog_category_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <referenceContainer name="content">
        <referenceBlock class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list">
            <action method="setDefaultDirection">
                <argument name="dir" xsi:type="string">desc</argument>
            </action>
        </referenceBlock>
    </referenceContainer>
    </body>
</page>

Please let us know if we missed anything.

Thanks

m2-assistant[bot] commented 1 week ago

Hi @engcom-Hotel. 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: :point_down:

ioweb-gr commented 1 week ago

Hello @engcom-Hotel , I think you missed steps 3 and 4. From the screenshots your provide it doesn't seem like you tried to change the direction to asc by clicking on the arrow link. Thank you for looking into this.

engcom-Hotel commented 1 week ago

Hello @ioweb-gr,

We have tried that as well. But the issue is still not reproducible for us. Please have a look at the below screencast: Category-2.webm

Let us know if we missed anything.

Thanks

ioweb-gr commented 1 week ago

I also tested this again on a fresh installation of 2.4.7 and it doesn't happen, so I can guess it's most likely a conflict with a third party module even though only a couple are installed. Thank you for verifying and let's close this issue