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

Cart price rule with condition SKU dosen't take into account the "leading zeros" in the SKU (sku: 01234 is the same as 1234) #37919

Open
1 of 5 tasks
matejslo opened this issue Aug 25, 2023 · 13 comments · May be fixed by #39525
Assignees
Labels
Area: Admin UI Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: PR in progress Reported on 2.4.4 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

@matejslo
Copy link

Preconditions and environment

Magento ver. 2.4.4

Steps to reproduce

  1. Create product with SKU: 1234
  2. Create product with SKU: 01234
  3. Create CART PRICE RULE (for example):
  • Specific coupon
  • Coupon code: TESTSKU
  • ACTION: percent of product price discount, 50% discount amount)
  • Apply the rule only to cart items ... (SKU is 01234)
  1. Go to shop front and add product SKU 1234 to CART
  2. On the cart page enter the coupon code TESTSKU

Expected result

Discount for product with SKU: 1234 of 50% should NOT be applied.

Actual result

Discount for product with SKU: 1234 IS applied (even the SKU is not in the CART PRICE RULE CONDITION).

Additional information

It seems that Magento 2 doesn't recognize the leading zeros of SKU.

From our diagnosis it seems that the problem is here:
\Magento\Rule\Model\Condition\AbstractCondition::_compareValues

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 Aug 25, 2023

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


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ 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.

@matejslo matejslo changed the title Cart price rule with condition SKU dosen't take into account the "leading zeros" in the SKU. Cart price rule with condition SKU dosen't take into account the "leading zeros" in the SKU (sku: 01234 is the same as 1234) Aug 25, 2023
@engcom-Dash engcom-Dash self-assigned this Aug 25, 2023
@m2-assistant
Copy link

m2-assistant bot commented Aug 25, 2023

Hi @engcom-Dash. 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).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. 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!

@engcom-Dash engcom-Dash added the Reported on 2.4.4 Indicates original Magento version for the Issue report. label Aug 25, 2023
@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

Hi @matejslo ,

verified the issue in 2.4-develop instance and issue can be reproducible,Hence we are confirming the issue,Kindly refer the below screenshots:
Screenshot 2023-08-30 at 5 47 55 PM
Screenshot 2023-08-30 at 5 48 24 PM
Screenshot 2023-08-30 at 5 49 30 PM

Thanks.

@engcom-Dash engcom-Dash added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Admin UI and removed Issue: ready for confirmation labels Aug 30, 2023
@github-jira-sync-bot
Copy link

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

@m2-assistant
Copy link

m2-assistant bot commented Aug 30, 2023

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

@engcom-Bravo engcom-Bravo added the Priority: P3 May be fixed according to the position in the backlog. label Aug 30, 2023
@Kiraberos
Copy link
Contributor

@magento I am working on it

@alicedfisheye
Copy link

alicedfisheye commented Feb 15, 2024

I have tested using the following patch and this has worked as expected for me.

index d5d3b80..2727e39 100644
--- a/Model/Condition/AbstractCondition.php
+++ b/Model/Condition/AbstractCondition.php
@@ -887,7 +887,7 @@ abstract class AbstractCondition extends \Magento\Framework\DataObject implement
     {
         if (null === $value || null === $validatedValue ||
             $strict && is_numeric($validatedValue) && is_numeric($value)) {
-            return $validatedValue == $value;
+            return $validatedValue === $value;
         }

         $validatePattern = preg_quote((string) $validatedValue, '~');

I am on version 2.4.3-p1. It looks like it is working as expected on version 2.4.6-p1, however, this is not the fix that was done. I could not find the exact fix done by Adobe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Admin UI Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: PR in progress Reported on 2.4.4 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: Ready for Development
Development

Successfully merging a pull request may close this issue.

7 participants