Skip to content

Cart Sales Rule with negated condition over special_price does not work for configurable products #14020

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

Closed
Filipe-Bicho opened this issue Mar 9, 2018 · 5 comments
Assignees
Labels
Event: kiev-cd Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@Filipe-Bicho
Copy link

Preconditions

  1. magento 2.2.3
  2. php 7.1.10
  3. mariadb 10.1.24

Steps to reproduce

  1. Setup vanilla 2.2.3 with demodata (or use a similar existing store)
  2. Enable the special_price for promo rule conditions:
    1. Stores > Attributes > Product
    2. Search for and edit special_price
    3. Storefront Properties: Use for Promo Rule Conditions: Yes
    4. Save
  3. create new cart sales rule:
    1. Marketing > Cart Price Rules
    2. Add New Rule:
      1. Rule name = "Special Price Test"
      2. Website: select all
      3. Customer Groups: select all
      4. Coupon: "Specific Coupon"
      5. Coupon Code: "special"
      6. Actions: Discount Amount: "10"
      7. Actions: Apply the rule only to cart items matching the following conditions: "if ALL of these conditions are FALSE": "Special Price greater than 0.01"
      8. Leave all other fields to their defaults and save
  4. In the front end, add a the child product of a configurable product to the cart, such that the child product has a special price set. This product should be the only one in the cart.
  5. "View and Edit Cart" > "Apply Discount Code": special

Expected result

  1. the coupon is not accepted with the message The coupon code "special" is not valid.
  2. no discount is applied

Actual result

  1. the coupon is accepted with the message You used coupon code "special".
  2. a discount is applied

The intention with the above mentioned sales rule is to exclude already discounted products from further discounting via a coupon code.

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Mar 9, 2018
@ktruehl
Copy link

ktruehl commented Mar 9, 2018

The problem manifests itself in the rule validation mechanism. For configurable products both the associated and the parent product is handed to the validate() method in Magento\Rule\Model\Condition\Product\AbstractProduct. But for special prices the special_price attribute is not defined. So in validate() in Magento\Rule\Model\Condition\AbstractCondition the call $model->getData($this->getAttribute()) will always return null for the parent product and thus validate to false. Thus price rule conditions using the special_price attribute will always validate to false for configurable products.

We have created a quickfix for this issue: bugfix-GH11178-configurable_product_sales_rule_special_price_validation.2018-02-06.diff.zip. It is only that, i.e. a quickfix. A more comprehensive fix would be to check Magento\Rule\Model\Condition\Product\AbstractProduct::validate() whether an attribute is defined at all for a specific product, and if not, to validate to true.

@magento-engcom-team
Copy link
Contributor

@Filipe-Bicho, thank you for your report.
We've acknowledged the issue and added to our backlog.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Mar 9, 2018
@sunilit42
Copy link
Contributor

I am working on this at #dmcdindia

@novikor
Copy link
Contributor

novikor commented Jun 22, 2018

#kiev-cd

@novikor novikor self-assigned this Jun 22, 2018
novikor added a commit to novikor/magento2 that referenced this issue Jun 22, 2018
…ce-does-not-work-for-configurable-products.

Use configurable product`s children for shopping cart rules validation
for cases when attribute exists for children only (E.g. special_price)
novikor added a commit to novikor/magento2 that referenced this issue Jul 4, 2018
…ce-does-not-work-for-configurable-products.

Revert "Removed dependency to configurable product"

This reverts commit d2a0de8.
novikor added a commit to novikor/magento2 that referenced this issue Jul 4, 2018
…ce-does-not-work-for-configurable-products.

Made getProductToValidate method private according to Technical Guideline (2.7)
novikor added a commit to novikor/magento2 that referenced this issue Jul 7, 2018
…ce-does-not-work-for-configurable-products.

Added configurable product to dependencies
novikor added a commit to novikor/magento2 that referenced this issue Jul 22, 2018
…cial-price-does-not-work-for-configurable-products. Added configurable product to dependencies"

This reverts commit 887ee4a
novikor added a commit to novikor/magento2 that referenced this issue Jul 22, 2018
…gated-condition-over-special-price-does-not-work-for-configurable-products

# Conflicts:
#	app/code/Magento/SalesRule/Model/Rule/Condition/Product.php
novikor added a commit to novikor/magento2 that referenced this issue Jul 22, 2018
…ce-does-not-work-for-configurable-products.

Restored \Magento\SalesRule\Model\Rule\Condition\Product to its previous state except PHPDocs.
novikor added a commit to novikor/magento2 that referenced this issue Jul 23, 2018
…ce-does-not-work-for-configurable-products

Removed an empty line.
novikor added a commit to novikor/magento2 that referenced this issue Aug 9, 2018
…Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products
novikor added a commit to novikor/magento2 that referenced this issue Aug 9, 2018
…th-negated-condition-over-special-price-does-not-work-for-configurable-products' into magento#14020-Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products
novikor added a commit to novikor/magento2 that referenced this issue Aug 9, 2018
…ce-does-not-work-for-configurable-products.

Unit tests coverage: case when child should be used
novikor added a commit to novikor/magento2 that referenced this issue Aug 9, 2018
…ce-does-not-work-for-configurable-products.

Fixed mock objects comparison
novikor added a commit to novikor/magento2 that referenced this issue Aug 9, 2018
…ce-does-not-work-for-configurable-products.

Fixed static tests.
novikor added a commit to novikor/magento2 that referenced this issue Aug 12, 2018
…Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Event: kiev-cd Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants