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

Add validation greater than zero for Maximum Qty Allowed in Shopping Cart for fixed #23319 #23635

Closed

Conversation

ravi-chandra3197
Copy link
Contributor

@ravi-chandra3197 ravi-chandra3197 commented Jul 9, 2019

Description (*)

Add validation greater than zero for Maximum Qty Allowed in Shopping Cart for fixed #23319

Fixed Issues (if relevant)

  1. Unable to save edited product when max_sale_qty is Magento's default #23319: Unable to save edited product when max_sale_qty is Magento's default

Manual testing scenarios (*)

  1. Go to admin area
  2. Go to Stores->Configuration->Catalog->Inventory->Product Stock Options
  3. Edit the global default Maximum Qty Allowed in Shopping Cart to be 0
  4. Save the config

Questions or comments

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 Jul 9, 2019

Hi @ravi-chandra3197. 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 give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

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

@rogyar
Copy link
Contributor

rogyar commented Jul 9, 2019

Hi @ravi-chandra3197 I've just checked the original issue and the following mention in particular:

Save is not happening, validation is failed due to validate-grater-then-0 on max_sale_qty field.

So, the problem is the system allows to set 0 as the global default value but does not allow saving product with 0 because of additional validation.
In your PR you introduce another validation that validates values greater than 0. Would you provide more information on how the additional "greater than 0" validation solves the existing "greater than 0" validation?
Thank you.

@ravi-chandra3197
Copy link
Contributor Author

Hi @ravi-chandra3197 I've just checked the original issue and the following mention in particular:

Save is not happening, validation is failed due to validate-grater-then-0 on max_sale_qty field.

So, the problem is the system allows to set 0 as the global default value but does not allow saving product with 0 because of additional validation.
In your PR you introduce another validation that validates values greater than 0. Would you provide more information on how the additional "greater than 0" validation solves the existing "greater than 0" validation?
Thank you.

Hello @rogyar
I have debugged and found that currently, Magento allows saving Maximum Qty Allowed in Shopping Cart to 0 because only validate-number is used.
I have added for validate-greater-than-zero because when we edit product and use the default config value so it creates an issue because for edit product have validation with PR ##18481
The problem seems to be introduced with this fix: #18477

@rogyar
Copy link
Contributor

rogyar commented Jul 10, 2019

Hi @ravi-chandra3197. Thank you for the explanation. My point is, you are still not able to save the product. The original issue says "Unable to save edited product when max_sale_qty is Magento's default". Please, use the steps from the original issue:

Go to admin area
Go to Stores->Configuration->Catalog->Inventory->Product Stock Options
Edit the global default to be 0
Save the config
Open create a simple product form and fill in minimum required data
Open the advanced inventory popup
Uncheck the checkbox "use_config_max_sale_qty"
Observe the default value of 0 in max_sale_qty field
Do not edit the default provided
Click Save

Then check if your fix provides the expected result:

Expected result
Product is successfully saved

Thank you

@ravi-chandra3197
Copy link
Contributor Author

Hi @ravi-chandra3197. Thank you for the explanation. My point is, you are still not able to save the product. The original issue says "Unable to save edited product when max_sale_qty is Magento's default". Please, use the steps from the original issue:

Go to admin area
Go to Stores->Configuration->Catalog->Inventory->Product Stock Options
Edit the global default to be 0
Save the config
Open create a simple product form and fill in minimum required data
Open the advanced inventory popup
Uncheck the checkbox "use_config_max_sale_qty"
Observe the default value of 0 in max_sale_qty field
Do not edit the default provided
Click Save

Then check if your fix provides the expected result:

Expected result
Product is successfully saved

Thank you

Hello @rogyar
so your point of view we should allow saving Maximum Qty Allowed in Shopping Cart with 0 value?

I think we have validated global default value and restrict save with 0, because whenever we use
the default value in the product where we have restricted to save Maximum Qty Allowed in Shopping Cart with 0 value so we have to validate default value before save.

@rogyar
Copy link
Contributor

rogyar commented Jul 12, 2019

Hi @ravi-chandra3197. That's correct, to solve this issue we should either allow or disallow 0 value everywhere to avoid confusions. I believe adding a validation "greater than zero" everywhere is the best option.

@rogyar
Copy link
Contributor

rogyar commented Jul 16, 2019

Just want to double-check we are on the same page. To proceed with the current solution we need to add additional validation for the global default (Stores -> Configuration -> Catalog -> Inventory)

@sidolov
Copy link
Contributor

sidolov commented Jul 29, 2019

@ravi-chandra3197 , I am closing this PR now due to inactivity.
Please reopen and update if you wish to continue.
Thank you for the collaboration!

@sidolov sidolov closed this Jul 29, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jul 29, 2019

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

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.

Unable to save edited product when max_sale_qty is Magento's default
4 participants