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.5k stars 9.31k forks source link

Sorting of configurable products on category pages is affected by the child product data #37508

Open hewgim opened 1 year ago

hewgim commented 1 year ago

Preconditions and environment

Magento vanilla version 2.4.5 and 2.4.6 with sample data Elastic Search 7

Steps to reproduce

Create a new sort attribute called Custom Sort Order with drop down values 1,2,3,4,5

Add the Custom Sort Order attribute to the 'Top' attribute set

Set the Custom Sort order to 3 for all Tops

For the Juno Jacket configurable product set the custom sort order to 5

For the Juno Jacket child products set the custom sort order to 2

Goto to Women->Tops->Jackets and sort by Custom Sort Order

Expected result

The Juno Jacket configurable product should display last in the Jackets category because it has the highest sort order

Actual result

The Juno Jacket does not display last.

However if you now set all the Juno Jacket children with a sort priority of 5, the Juno Jacket configurable product will display last.

That means that the sorting of a parent configurable product is dependent on the sort data of both the parent and its children which doesn't make sense and is rather confusing. This appears to be behaviour brought in by the use of Elastic Search rather than MySql

Additional information

It is interesting to note that when you reverse the direction of the sort the Juno Jacket does appear first as expected.

I ran this in a debugger and stopped in vendor/magento/module_elastic_search-7/SearchAdapter/Adapter.php which appears to be used to obtain the sorted list of products. When I look at the $rawResponse array I can see that the sort data for the Juno Jacket configurable product contains the Custom Sort Order data from the children. When the direction of sorting is reversed the sort data contains the Custom Sort Order data from the parent.

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @hewgim. 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. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 1 year ago

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

engcom-Bravo commented 1 year ago

Hi @hewgim,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

Juno Jacket Configurable product displaying last in the jackets category.

Jackets-Tops-Women

Kindly recheck the behaviour on Magento 2.4-develop instance and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

hewgim commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @hewgim. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @hewgim, here is your Magento Instance: https://3639c42b336a0e3ce5ccb53ccde1073a.instances-prod.magento-community.engineering Admin access: https://3639c42b336a0e3ce5ccb53ccde1073a.instances-prod.magento-community.engineering/admin_edfe Login: 70253529 Password: 8a8853934e95

hewgim commented 1 year ago

Hi @engcom-Bravo

Apologies but I missed a crucial step in the steps to reproduce.

For the Juno Jacket child products set the custom sort order to 2

I've amended the Steps To Reproduce above.

After I do this the Juno jacket appears first when it should appear last

Screenshot 2023-05-18 at 11 50 56
m2-assistant[bot] commented 1 year ago

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

engcom-November commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-November, here is your Magento Instance: https://3639c42b336a0e3ce5ccb53ccde1073a.instances-prod.magento-community.engineering Admin access: https://3639c42b336a0e3ce5ccb53ccde1073a.instances-prod.magento-community.engineering/admin_92e2 Login: 917ace22 Password: 480125c6bd46

engcom-Bravo commented 1 year ago

HI @hewgim,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible, but it seems to be expected behaviour of Magento.Kindly refer the screenshots.

We have set Juno Jacket child products custom sort order to 2.Juno Configurable product displaying because other configurable product child products not having custom sort values.

Jackets-Tops-Women (1)

Here we have set Stellar Solar Jacket child products custom sort order to 1 and juno jacket child products to 5 and stellar displaying first because it has sort value has 1 and juno displaying last it has sort value has 5.

Jackets-Tops-Women (2)

Previously https://github.com/magento/magento2/issues/37508#issuecomment-1551519653 here juno product displaying last because it has sort value has 5 and other product child products not having sort values so in that case products are showing based on parent product sort values.

Kindly recheck the behaviour on Magento 2.4-develop instance and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

hewgim commented 1 year ago

Hi @engcom-Bravo, You say that this is expected behaviour, but it is not at all obvious to the end user, or to me a web developer. It doesn't seem at all logical that the sort position of a visible parent product is dictated by the data of it's children. Why should the child data take precedence over the data of the parent itself when determining the sort position of the parent ?

If you imagine sorting by product name ascending I would expect the data to be sorted by the product name of the visible products. Imagine if the children of the Juno Jacket were called 'Blue Juno Jacket' for example. Now the sort by product name wouldn't sort the parents in alphabetical order, which would be confusing to the user.

IMHO this behaviour is not correct. The data of the visible product should take precedence over the data of invisible children, or not take into account the data of the invisible children at all.

Regards

Mark

hewgim commented 1 year ago

Hi @engcom-Bravo , Any update on this ? It's crazy that the sorting of the visible configurable parent products is controlled by the data of the invisible children rather than by the parent product itself. I'm a developer and my clients are confused by this as am I. It felt like category page sorting was completely broken until I realised what was going on. My clients just want to easily control the placement of their configurable products on the category pages. Now I have to tell them they have to set the sort priority on both the parent and all its children to get the results they want. That doesn't seem right.

engcom-Bravo commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @engcom-Bravo, here is your Magento Instance: https://3639c42b336a0e3ce5ccb53ccde1073a.instances-prod.magento-community.engineering Admin access: https://3639c42b336a0e3ce5ccb53ccde1073a.instances-prod.magento-community.engineering/admin_1992 Login: 49df9a33 Password: 68e639307c7e

engcom-Bravo commented 1 year ago

Hi @hewgim,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Steps to reproduce

Jackets-Tops-Women (3)

Jackets-Tops-Women (4)

Juno Configurable product displaying first in the order. Since the child products having product visibility has Not Visible Individually.As per Magento devdocs the products having visibility has Not Visible Individually The product is not included in your storefront listings, although it might be available as a variation of another product, Hence it should not effect the parent product sorting.

Hence Confirming this issue.

Thanks.

github-jira-sync-bot commented 1 year ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-8991 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 year ago

:white_check_mark: 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.