Skip to content

[Bugfix] #7333 Unable to set negative custom option fixed price in admin view. #15267

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

Merged
merged 10 commits into from
Jan 14, 2019
Merged

[Bugfix] #7333 Unable to set negative custom option fixed price in admin view. #15267

merged 10 commits into from
Jan 14, 2019

Conversation

dverkade
Copy link
Member

Fixes the ability to set a negative custom option price in the backend.

Description

In Magento 1 it was possible to set a negative price change to a custom option. This PR fixes issue #7333 and makes it possible to set a negative price in the backend of Magento. This PR fixes the backend so that the negative price change can actually be entered in the Magento admin. There is a separate PR for the frontend changes which is PR #14975

There also seem to be two other PR's for this issue which are stale and are not moving along:
#13393
#14342

Fixed Issues

  1. Unable to set negative custom option fixed price in admin view. #7333: Unable to set negative custom option fixed price in admin view.

Manual testing scenarios

  1. Create a new simple product in the backend and try to create new custom options where the price change has a negative value (for instance, "-10").

@dverkade dverkade changed the title Fix #7333 Unable to set negative custom option fixed price in admin view. [Bugfix] #7333 Unable to set negative custom option fixed price in admin view. May 16, 2018
@miguelbalparda
Copy link
Contributor

Tests are failing, any chance you can review them?

@dverkade dverkade self-assigned this May 23, 2018
@dverkade
Copy link
Member Author

Will work on this at the MM18NL contribution day.

…ice in admin view.

 - Fixed unit tests
 - Fixed integration tests
 - Changed defaultvalidator to have the locale format interface. Because a value entered in the backoffice of Magento is passed as the value like "40,000.00", which needs to be converted to a float in order to do a valid check on it.
@dmanners dmanners added the mm18nl label Jun 2, 2018
@dverkade
Copy link
Member Author

dverkade commented Jun 2, 2018

All tests are now green. Please proceed with processing this PR.

* @param string $value
* @return bool
*/
protected function isNumber($value)
Copy link
Contributor

Choose a reason for hiding this comment

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

So @dverkade looking over this pr again I think we should be making this method public. We are trying to stay away from protected and since these classes are built with inheritance in mind I would suggest that having this method public would allow for a user to create a new validator and change the isNumber functionality.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @dmanners, thanks for reviewing this. I have changed the function to public.

@dverkade
Copy link
Member Author

dverkade commented Jun 5, 2018

Changes have been made, this PR can be processed / reviewed again.

@dmanners
Copy link
Contributor

dmanners commented Jun 6, 2018

Thanks for those changes @dverkade there are two failures with the api tests but I will investigate these for you and then process this pr.

@ihor-sviziev
Copy link
Contributor

Hi @dmanners,
Could you also look into #14342? Looks like these PRs fixing one issue

@dmanners
Copy link
Contributor

Will do @ihor-sviziev thanks for the note.

@dmanners
Copy link
Contributor

Hi @dverkade just to keep you updated I am checking with the core team to understand the reasoning for making negative prices not allowed a bit better, just to make sure that we do not miss something important out. After I have more information I will update you via this PR. Thanks for your patience.

@dmanners
Copy link
Contributor

Hi @dverkade sorry for the delay. Would you be able to look into the test Magento\Catalog\Api\ProductCustomOptionRepositoryTest::testAddNegative It is used to validate that there are no negative prices added for options. In this case I would suggest that we test the addition of negative prices and validate that you can add them. This way if someone happens in the future to this feature we are able to see it.

@dmanners
Copy link
Contributor

dmanners commented Sep 4, 2018

Hi @dverkade any update here?

…m-option

# Conflicts:
#	app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php
#	app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php
#	app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/DefaultValidatorTest.php
#	app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/FileTest.php
#	app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/SelectTest.php
#	app/code/Magento/Catalog/Test/Unit/Model/Product/Option/Validator/TextTest.php
@dverkade
Copy link
Member Author

dverkade commented Sep 5, 2018

Hi @dmanners,

Thanks for your patience. This has been resolved by merging the 2.3 develop branch into this PR. Merge conflicts have been resolved. You can proceed with checking this PR.

@dmanners
Copy link
Contributor

Thanks @dverkade got one more failure coming through.

Magento\Catalog\Api\ProductCustomOptionRepositoryTest::testGetList
Failed asserting that 10 matches expected 11.

Could you take a look at this for me.

@dverkade
Copy link
Member Author

Hi @dmanners,

I have taken a look at this test and fixed the issue. The API functional test should now pass as well.

@sidolov
Copy link
Contributor

sidolov commented Oct 2, 2018

Hi @dverkade , please, resolve merge conflict.
Thanks!

…7333-negative-value-for-custom-option

# Conflicts:
#	app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php
@dverkade
Copy link
Member Author

dverkade commented Oct 2, 2018

@dmanners @sidolov merge conflict is resolved.

@magento-engcom-team
Copy link
Contributor

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

@dverkade
Copy link
Member Author

@dmanners @sidolov when will this PR be processed? Had been in this state since the 4th of October.

@magento-engcom-team magento-engcom-team merged commit 4927e56 into magento:2.3-develop Jan 14, 2019
@ghost
Copy link

ghost commented Jan 14, 2019

Hi @dverkade, 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.

@magento-engcom-team
Copy link
Contributor

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

magento-engcom-team pushed a commit that referenced this pull request Jan 14, 2019
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.

7 participants