Skip to content

#14020-Cart-Sales-Rule-with-negated-condition-over-special-price-does… #16342

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

Conversation

novikor
Copy link
Contributor

@novikor novikor commented Jun 22, 2018

…-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)

Description

Fixed Issues (if relevant)

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

Manual testing scenarios

  1. 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
  2. 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
  3. 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.
  4. "View and Edit Cart" > "Apply Discount Code": special

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

…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)
@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Jun 22, 2018

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @novikor. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

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

Copy link
Contributor

@phoenix128 phoenix128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @novikor ,
thank you for your contribution.
We appreciate your support.

@magento-engcom-team
Copy link
Contributor

Hi @phoenix128, thank you for the review.
ENGCOM-2111 has been created to process this Pull Request

@phoenix128 phoenix128 requested a review from sidolov June 26, 2018 14:26
@novikor
Copy link
Contributor Author

novikor commented Jun 30, 2018

@phoenix128 , please revert d2a0de8

This functionality have been implemented for configurable products only, not for all composite types.

Moreover, Unit tests will not fail if this commit is reverted.

Thank you.

* @return \Magento\Catalog\Api\Data\ProductInterface|\Magento\Catalog\Model\Product
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
protected function getProductToValidate(\Magento\Framework\Model\AbstractModel $model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make this method private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please review: fae98c0 & 9a35b45

novikor added 2 commits July 4, 2018 22:55
…ce-does-not-work-for-configurable-products.

Revert "Removed dependency to configurable product"

This reverts commit d2a0de8.
…ce-does-not-work-for-configurable-products.

Made getProductToValidate method private according to Technical Guideline (2.7)
@novikor novikor added the Partner: ISM eCompany Pull Request is created by partner ISM eCompany label Jul 6, 2018
@novikor novikor assigned sidolov and unassigned phoenix128 Jul 7, 2018
…ce-does-not-work-for-configurable-products.

Added configurable product to dependencies
@novikor
Copy link
Contributor Author

novikor commented Jul 16, 2018

@sidolov , are there any updates?

@sidolov
Copy link
Contributor

sidolov commented Jul 17, 2018

Hi @novikor , we are trying to avoid new dependencies across Magento modules and define another one it's not a good idea. If you have the specific case for the configurable product during the rule processing it would be better to use default Magento ways for extensibility (plugins, DI configuration, etc).

@novikor novikor assigned novikor and unassigned sidolov Jul 22, 2018
novikor added 3 commits July 22, 2018 12:30
…cial-price-does-not-work-for-configurable-products. Added configurable product to dependencies"

This reverts commit 887ee4a
…gated-condition-over-special-price-does-not-work-for-configurable-products

# Conflicts:
#	app/code/Magento/SalesRule/Model/Rule/Condition/Product.php
…ce-does-not-work-for-configurable-products.

Restored \Magento\SalesRule\Model\Rule\Condition\Product to its previous state except PHPDocs.
@novikor novikor added the partners-contribution Pull Request is created by Magento Partner label Jul 22, 2018
@novikor novikor force-pushed the #14020-Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products branch from c1a780e to 618f408 Compare July 22, 2018 20:10
{
/**
* @param \Magento\SalesRule\Model\Rule\Condition\Product $subject
* @param \Magento\Framework\Model\AbstractModel $model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove extra spaces


/**
* @param \Magento\SalesRule\Model\Rule\Condition\Product $subject
* @param \Magento\Framework\Model\AbstractModel $model
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove extra spaces

@@ -0,0 +1,53 @@
<?php declare(strict_types=1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, cover new code at least by the unit test. It would be great if scenario will be covered with integration test

Copy link
Contributor Author

@novikor novikor Aug 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests coverage have been implemented.
@sidolov, please check.

novikor added 4 commits August 9, 2018 13:24
…Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products
…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
…ce-does-not-work-for-configurable-products.

Unit tests coverage: case when child should be used
…ce-does-not-work-for-configurable-products.

Fixed mock objects comparison
@novikor novikor force-pushed the #14020-Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products branch from 02bf4e0 to 870faf1 Compare August 9, 2018 14:01
@novikor novikor force-pushed the #14020-Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products branch from 870faf1 to c52e0e8 Compare August 9, 2018 14:02
…ce-does-not-work-for-configurable-products.

Fixed static tests.
@novikor novikor assigned sidolov and unassigned novikor Aug 10, 2018
…Cart-Sales-Rule-with-negated-condition-over-special-price-does-not-work-for-configurable-products
@novikor
Copy link
Contributor Author

novikor commented Oct 5, 2018

@sidolov , any updates?

@sidolov
Copy link
Contributor

sidolov commented Oct 8, 2018

Hi @novikor , we found the problems with this solution on the B2B edition and trying to figure it out right now.
Thank you for your patience.

@magento-engcom-team
Copy link
Contributor

Hi @novikor. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants