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.55k stars 9.32k forks source link

Magento 2 Related Products rule always returns the same products which meet the rule requirements #32489

Open mtwegrzycki opened 3 years ago

mtwegrzycki commented 3 years ago

Preconditions (*)

  1. Magento 2.4.2

Steps to reproduce (*)

  1. Add e.g. 10 products (more than "Result limit" from point 2.) to Magento store, which meet the specified Related/Cross-Sell/Up-Sell "Products to Display" conditions.
  2. Set "Result limit" for rule e.g. on 2.
  3. Search a product which meets the "Product to Match" conditions
  4. Check the Related/Cross-Sell/Up-Sell products

Expected result (*)

  1. I get different products for each searching.

Actual result (*)

  1. I always get the same two products. There are the products with the lowest IDs, which meet rule conditions.
  2. It does not matter how much products from database meet the rule conditions.
  3. It is caused by SQL query to get products from database for specified rule.
  4. Always the same two products are returned from database. Result from database should be randomized.

Maximum "Result limit" is 20 and it is fine for performance, but currently, if we have e.g. 50 products which meet the rule conditions, only first 20 products with the lowest IDs will be displayed to customer and it is not good from business perspective. Results should be randomized on database query level.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 3 years ago

Hi @mtwegrzycki. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

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

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

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

mtwegrzycki commented 3 years ago

@magento I am working on this

m2-assistant[bot] commented 3 years ago

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

magento-engcom-team commented 3 years ago

:white_check_mark: Confirmed by @engcom-Oscar Thank you for verifying the issue. Based on the provided information internal tickets MC-41444 were created

Issue Available: @engcom-Oscar, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Kiraberos commented 2 years ago

@magento I am working on this

Kiraberos commented 2 years ago

@mtwegrzycki I want to clarify: What did you mean about 'Set "Result limit" for rule e.g. on 2.'? In the admin panel we didn't set result limits for related, upsell and cross-sell. According to the project, I can't find a use for this condition 'related-rule'. image

In Magento/Catalog/view/frontend/templates/product/list/items.phtml I see that such conditions exist, but it looks like there should be an appropriate functionality for these conditions. There is a $shuffle variable to which the value from the function is assigned isShuffled().This functionality should solve this problem. image But this functionality is in the commercial version. The module is responsible for it Magento_TargetRule. And thanks to this functionality we can randomize the result for related, upsell and cross-sell products.

Therefore, perhaps you should reconsider this pr and the task.