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

magento/magento2#22856: Catalog price rules are not working with custom options as expected. #22917

Merged
merged 8 commits into from
Jan 8, 2020

Conversation

p-bystritsky
Copy link
Contributor

@p-bystritsky p-bystritsky commented May 16, 2019

Description (*)

Fixed Issues (if relevant)

  1. Catalog pricerules are not working with custom options as expected in Magento 2.3.0 product details page #22856: Catalog price rules are not working with custom options as expected.

Manual testing scenarios (*)

  1. Create Product1 with fixed price custom options.
  2. Create Product2 with percent price custom options.
  3. Create and apply CatalogPriceRule1 with percent type discount.
  4. Open Product1 and Product2 pages on the storefront and make sure discount is correctly applied to products options.
  5. Disable CatalogPriceRule1.
  6. Create and apply CatalogPriceRule2 with fixed type discount.
  7. Open Product1 and Product2 pages on the storefront and make sure discount is correctly applied to products options.

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 are green)

@m2-assistant
Copy link

m2-assistant bot commented May 16, 2019

Hi @p-bystritsky. 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 2.3-develop instance - deploy vanilla Magento instance

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

* return converted percent to price
* Return price.
*
* If $flag is true and price is percent return converted percent to price
*
Copy link
Contributor

Choose a reason for hiding this comment

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

I take this comment as an example of very good and less good use of it at the same time.

When you say something like "if $flag is true..." it is very valuable but at the same time saying "Return price" on a method named getPrice() doesn't add any additional value.

Next time, I would recommend avoiding comments that repeat the name of the method, just use a comment to explain something that's not very explicit, that way you will add valuable info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aleron75 thank you for the review! Unfortunately, code sniffers are forcing us to add some description to method annotation, so sometimes we have no other way then add some absolutely useless comment to old methods.

* @param ProductOptionValue $optionValue
* @return float
*/
public function execute(
Copy link
Contributor

Choose a reason for hiding this comment

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

The execute() method underscores the functional usage of a service class, that's a correct approach.

For this reason, a better name for the class would be one that suggests the command that is executed, like CalculateCustomOptionCatalogRule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aleron75 done.

@magento-engcom-team
Copy link
Contributor

Hi @aleron75, thank you for the review.
ENGCOM-5122 has been created to process this Pull Request
✳️ @aleron75, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@engcom-Delta engcom-Delta self-assigned this Jun 25, 2019
@engcom-Delta
Copy link
Contributor

engcom-Delta commented Jun 25, 2019

Hi @p-bystritsky issue is also reproducible with custom option type Field. Could you take a look?
Manual testing scenario:

  1. Create Product1 with Price=100$ and with fixed price custom options.
  • Option Type=Field
    • Price=10$
    • Price Type=Fixed
  1. Create and apply CatalogPriceRule1 with percent type discount.
  • Conditions:
    • Category is {your category with products}
  • Actions:
    • Apply=Apply as percentage of original
    • Discount Amount =50
  1. Open Product1 page on the storefront

Result:
Catalog rule discount is applied only for base product price so final price is {{ (Product Price * Discount Amount) + Custom Option Price }}
#22917Pr

@sdzhepa
Copy link
Contributor

sdzhepa commented Dec 2, 2019

@magento run all tests

@sidolov sidolov changed the base branch from 2.3-develop to 2.4-develop December 5, 2019 17:20
@p-bystritsky p-bystritsky force-pushed the ISSUE-22856 branch 2 times, most recently from bb39c32 to abca0b8 Compare December 6, 2019 11:43
@johncarlson21
Copy link

guys where are we at with this? I cannot believe that no one else is making a stink about this issue.

@m2-assistant
Copy link

m2-assistant bot commented Jan 8, 2020

Hi @p-bystritsky, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@johncarlson21
Copy link

so what release will this be in?

@kunzi
Copy link

kunzi commented Jan 16, 2020

@johncarlson21 I guess it is going to be in 2.4 as it is in 2.4-develop branch. Not sure... I'm having this issue in M 1.9.3.1 too.

@johncarlson21
Copy link

@kunzi thanks.. I never had this problem in 1.9.x and that is why when I updated I didn't notice it right away, but our site relys on this function, can't believe it was missed.
Do you have any custom code etc that could be causing the problem on your site?

P.S. if anyone needs a quick fix for the above issue before the release, let me know as I've taken this code and put it into an extension for now.

@kunzi
Copy link

kunzi commented Jan 16, 2020

@johncarlson21 We actually do have an extension in M 1.9.3.1 that sets absolute price for each custom option. Maybe that causes it. Thanks for the hint.

@gsbhati2008
Copy link

@kunzi thanks.. I never had this problem in 1.9.x and that is why when I updated I didn't notice it right away, but our site relys on this function, can't believe it was missed.
Do you have any custom code etc that could be causing the problem on your site?

P.S. if anyone needs a quick fix for the above issue before the release, let me know as I've taken this code and put it into an extension for now.

Can you please send me extension for now as I need this now.

@ashar01
Copy link

ashar01 commented Oct 2, 2023

@johncarlson21 @sdzhepa @p-bystritsky This ticket says the issue is fixed but i am bit confused after reading this https://experienceleague.adobe.com/docs/commerce-knowledge-base/kb/support-tools/patches/v1-1-23/acsd-47107-catalog-price-rule-is-applied-to-custom-options.html?lang=en
This document says magento reverts this fix in m2.4.6 release.

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.