Skip to content
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

Product name wise sorting not working #36076

Open
5 tasks
sunilit42 opened this issue Sep 2, 2022 · 24 comments · May be fixed by #36265
Open
5 tasks

Product name wise sorting not working #36076

sunilit42 opened this issue Sep 2, 2022 · 24 comments · May be fixed by #36265
Assignees
Labels
Area: Catalog Component: Catalog Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reported on 2.4.5 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@sunilit42
Copy link
Contributor

sunilit42 commented Sep 2, 2022

Preconditions and environment

  • lastest magento
  • add product
  • create category and assign that product
  • consider page limit per page 12

Steps to reproduce

  • Category and that related product
  • open that category page
  • elasticsearch configure
  • click on sort by product name
  • find that first product that category into backend add store wise name entry
  • open that category page
  • you will page limit 12 but it is showing 11 if you do store wise entry

Expected result

  • it should be show all 12 products

Actual result

  • it is showing 11 products

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”.
@m2-assistant
Copy link

m2-assistant bot commented Sep 2, 2022

Hi @sunilit42. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@sunilit42
Copy link
Contributor Author

@magento give me 2.4-develop instance - upcoming 2.4.x release

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Hotel engcom-Hotel added the Reported on 2.4.5 Indicates original Magento version for the Issue report. label Sep 2, 2022
@engcom-November engcom-November self-assigned this Sep 5, 2022
@m2-assistant
Copy link

m2-assistant bot commented Sep 5, 2022

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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-November
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-November
Copy link
Contributor

Hi @sunilit42 , Thank you for reporting and collaboration.
Verified the issue on Magento 2.4-develop branch but the issue is not reproducible. Sort By Product Name - All 12 products are getting displayed per page and sorting is working on alphabetical order in the category page
image
Kindly recheck the issue on Magento 2.4-develop branch as it is having latest code base and provide missing steps if any if the issue is still reproducible.
Thank you.

@engcom-November engcom-November added the Issue: needs update Additional information is require, waiting for response label Sep 20, 2022
@engcom-November engcom-November added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Sep 20, 2022
@sunilit42
Copy link
Contributor Author

https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php#L239

Check this line , here is bug

if we enter name store wise name, coding doing sorting based on global name

i found that issue with EE endition and here may be also

@mirianfalconi
Copy link

@magento I am working on this

@m2-assistant
Copy link

m2-assistant bot commented Sep 22, 2022

Hi @mirianfalconi! 👋
Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

@mirianfalconi
Copy link

@magento add to contributors team

@m2-assistant
Copy link

m2-assistant bot commented Sep 22, 2022

Hi @mirianfalconi! 👋
Thank you for joining. Please accept team invitation 👉 here 👈 and add your comment one more time.

@mirianfalconi
Copy link

@magento add to contributors team

@mirianfalconi
Copy link

@magento I am working on this

@m2-community-project m2-community-project bot removed the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Sep 22, 2022
@m2-community-project m2-community-project bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Sep 27, 2022
@engcom-November
Copy link
Contributor

engcom-November commented Sep 28, 2022

Verified the issue again on Magento 2.4-develop instance but observed below different issue on Admin - Categories page.
Steps performed:

  1. Saved 12 products with different product names in All Store views scope, Default store view scope and other website scope
  2. Clean cache
  3. Verified front end - Category page of main website and other website
  4. sort by Product Name - No issue found
    Sorting working as expected and 12 products displayed per page.
  5. Verified Admin - Categories page - All Store Views scope - Products in Category - Default view - No issue.
    Product names displayed as expected
    Sort by Product Name - Issue: After applying sorting - Product names got changed to default store view product names.
    Bug logged for the same: Multiple Store views - Admin - Category page - Sorting by Product Name issue #36208
    Issue verification is in progress for Enterprise edition.

@engcom-November
Copy link
Contributor

engcom-November commented Sep 29, 2022

Verified the issue again on Magento 2.4-develop instance and the issue is reproducible for other website store (Other than default website). Hence confirming this issue.
Issue: Sorting with Product Name is giving 11 products in 1st page but the page limit is set to 12
image
image

@engcom-November engcom-November added Component: Catalog Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Reported on 2.4.x Indicates original Magento version for the Issue report. Area: Catalog labels Sep 29, 2022
@engcom-November engcom-November added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Sep 29, 2022
@github-jira-sync-bot
Copy link

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

@m2-assistant
Copy link

m2-assistant bot commented Sep 29, 2022

✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-November engcom-November removed their assignment Sep 29, 2022
@engcom-November engcom-November removed the Issue: needs update Additional information is require, waiting for response label Sep 29, 2022
@sunilit42
Copy link
Contributor Author

@magento I am working on this

@mirianfalconi
Copy link

@magento I am working on this

@mirianfalconi mirianfalconi linked a pull request Oct 11, 2022 that will close this issue
5 tasks
@zaximus84
Copy link

I ran into this issue as well. To provide additional detail, the problem with the name sort is that it joins the catalog_product_entity_varchar table in a way that can produce multiple rows for the same product in the final query. On my Magento installation we have 3 websites and lots of products have ended up with name values at the default scope and all 3 website scopes.

The final query executed in \Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplier::categoryProductByCustomSortOrder expects to return 12 distinct product ids, but due to joining the scoped names, it returns these 12 rows (where what appear to be duplicates are actually different store ids):

entity_id is_salable position name
518 1 123 Product Name
518 1 123 Product Name
518 1 123 Product Name
518 1 123 Product Name
270 1 51 Another Product Name
270 1 51 Another Product Name
270 1 51 Another Product Name
270 1 51 Another Product Name
414 1 105 Different Product Name
414 1 105 Different Product Name
414 1 105 Different Product Name
414 1 105 Different Product Name

As a result, only 518, 270, and 414 are returned, and only those 3 products show on the page. The solution here will be to properly group the query so only 1 row per entity id is returned, though that will be complicated by the need to include the product name for the proper scope for each product.

While not an actual fix for this issue, I worked around it on my installation by completely circumventing the logic with the flawed query. I patched Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplier and replaced this:

        $ids = $this->getProductIdsBySaleability();

        if (count($ids) == 0) {
            $items = $this->sliceItems($this->searchResult->getItems(), $this->size, $this->currentPage);
            foreach ($items as $item) {
                $ids[] = (int)$item->getId();
            }
        }

with this:

        $items = $this->sliceItems($this->searchResult->getItems(), $this->size, $this->currentPage);
        foreach ($items as $item) {
            $ids[] = (int)$item->getId();
        }

This removes the logic that's trying to show all in stock products before all the out of stock products, and it instead uses the results from Elasticsearch directly without running the additional query containing the bug.

@engcom-Hotel engcom-Hotel moved this to Pull Request In Progress in High Priority Backlog Aug 19, 2024
@engcom-Delta
Copy link
Contributor

Hi @sunilit42 ,

Thanks for your reporting and collaboration.
We have re-verified the issue in Latest 2.4-develop instance , but we are unable to reproduce the issue. Kindly refer the screenshots.

Steps to reproduce

  1. Create multiple websites
  2. Category and that related product
  3. open that category page
  4. click on sort by product name
  5. find that first product that category into backend add store wise name entry
  6. open that category page
  7. Observe all 12 products are displaying with sort applied.
    image

Can you please re-verify and confirm if you are still facing the issue.
Thanks.

@engcom-Delta engcom-Delta added Issue: needs update Additional information is require, waiting for response and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Catalog Component: Catalog Issue: needs update Additional information is require, waiting for response Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reported on 2.4.5 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Status: Pull Request In Progress
7 participants