Skip to content

type casted $qty to float in \Magento\Catalog\Model\Product::setQty() #18149

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 2 commits into from
Oct 3, 2018
Merged

type casted $qty to float in \Magento\Catalog\Model\Product::setQty() #18149

merged 2 commits into from
Oct 3, 2018

Conversation

jayankaghosh
Copy link
Contributor

@jayankaghosh jayankaghosh commented Sep 20, 2018

type casted $qty to float in \Magento\Catalog\Model\Product::setQty()

Description

\Magento\Catalog\Model\Product::getQty() should return float/double now, as mentioned in it's Doc-block

Fixed Issues (if relevant)

  1. Should getQty() return int/float or string? #18094: Should getQty() return int/float or string?

Manual testing scenarios

  1. Observe any event like checkout_cart_product_add_after
  2. In the Observer, get an instance of \Magento\Catalog\Model\Product
  3. Calling the getQty method of the above-mentioned class would return a float/double instead of string, as expected

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)

@magento-engcom-team
Copy link
Contributor

Hi @jayankaghosh. 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

@rogyar
Copy link
Contributor

rogyar commented Sep 20, 2018

Hi @jayankaghosh. Thank you for your collaboration.
By bringing the change provided in the current PR we only cover cases when the qty is set using setQty method. However, the product model extends AbstractExtensibleModel and qty can be set via setData('qty').
Maybe we should consider the change within a scope of the getter instead of setter

@jayankaghosh
Copy link
Contributor Author

@rogyar I made changes to the code to type case in the getter, but then the problem is everytime we get the price, type casting will occur, which may affect performance

@magento-engcom-team
Copy link
Contributor

Hi @jayankaghosh. 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.

Copy link

@Nurgiel Nurgiel left a comment

Choose a reason for hiding this comment

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

Should be int not float.

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.

6 participants