Skip to content

[ISM][#18651] TierPrice save float percentage value #19030

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

Closed
wants to merge 5 commits into from
Closed

[ISM][#18651] TierPrice save float percentage value #19030

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 2, 2018

Tierprice can't save float percentage value

Description

Problem:
After save tierprice for product, discount field lost value after comma.
Fix:
Updated getPercentage method in TierPrices:

  • Type conversation changed: int -> float
  • Added strict types
  • Database has remained unchanged since the percentage_value is a decimal field

Fixed Issues

  1. Tierprice can't save float percentage value #18651: Tierprice can't save float percentage value

Manual testing scenarios

  1. Add new product
  2. Add new tierprice with discount value "2.5"
  3. Save the product
  4. Value "2.5" is saved

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-cicd2
Copy link
Contributor

magento-cicd2 commented Nov 2, 2018

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team magento-engcom-team added Partner: ISM eCompany Pull Request is created by partner ISM eCompany partners-contribution Pull Request is created by Magento Partner Component: Catalog labels Nov 2, 2018
@magento-engcom-team
Copy link
Contributor

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

@ghost ghost changed the title [ISM][#18651 tierprice can t save float percentage value [ISM][#18651] tierprice can t save float percentage value Nov 2, 2018
@ghost ghost changed the title [ISM][#18651] tierprice can t save float percentage value [ISM][#18651] TierPrice save float percentage value Nov 2, 2018
*/
private function getPercentage(array $priceRow)
private function getPercentage(array $priceRow): ?float
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @SikailoISM, since Magento 2.2 supports PHP 7.0 you can't use nullable return types as this is a feature of PHP 7.1 and higher. See http://php.net/manual/en/migration71.new-features.php

*/
private function getPercentage(array $priceRow)
private function getPercentage(array $priceRow): ?float
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @SikailoISM, since Magento 2.2 supports PHP 7.0 you can't use nullable return types as this is a feature of PHP 7.1 and higher. See http://php.net/manual/en/migration71.new-features.php

@tkacheva
Copy link

tkacheva commented Nov 6, 2018

@SikailoISM Thanks for contributing this change! That's great to have tier discounts format aligned with catalog and cart promotions discounts

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

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

Nowadays all changes must be applied to 2.3-develop first. Please prepare a new pull request, this one should be on hold until the latter is merged.

{
return isset($priceRow['percentage_value']) && is_numeric($priceRow['percentage_value'])
? (int)$priceRow['percentage_value']
? (float)$priceRow['percentage_value']
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to cast explicitly to float, usually + 0 or * 1 is used to convert so that no unneeded int <-> float occur.

Copy link
Author

@ghost ghost Nov 10, 2018

Choose a reason for hiding this comment

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

• $priceRow['percentage_value'] + 0 or • $priceRow['percentage_value'] * 1
Is it relevant?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, of course.

@sidolov
Copy link
Contributor

sidolov commented Nov 28, 2018

Hi @SikailoISM , please, resolve merge conflicts

@ghost
Copy link
Author

ghost commented Nov 29, 2018

I give up

@ghost ghost closed this Nov 29, 2018
@ghost ghost deleted the ISM-18651-Tierprice-can-t-save-float-percentage-value branch November 30, 2018 07:22
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Partner: ISM eCompany Pull Request is created by partner ISM eCompany partners-contribution Pull Request is created by Magento Partner Progress: needs update Progress: on hold Release Line: 2.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants