Skip to content

Tiered pricing and quantity Increments do not work with decimal inventory MAGETWO-86164 (both front-end and back-end) #13359

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 1 commit into from

Conversation

vasilii-b
Copy link

Description

All issues below are described in #12914

Fixed Issues

[1] Cannot close Advanced Inventory pop-up after setting Qty Uses Decimals to No and having Enable Qty Increments enabled

Steps to reproduce:

  1. Create new product/ edit existing one
  2. Open Advanced Inventory pop-up under Quantity
  3. Set Qty Uses Decimals to Yes
  4. Set Qty value to decimal value
  5. Set Enable Qty Increments to Yes
  6. Set Qty Increments a decimal value
  7. Press DONE (may skip this step)
  8. Open Advanced Inventory pop-up under Quantity (optional if 7 was skipped)
  9. Set Set Qty Uses Decimals to No
  10. Set Qty value to integer value
  11. Set Enable Qty Increments to No
  12. Press DONE or the X icon to close the button

Expected Result

Close the Advanced Inventory pop-up

Actual result

Pop-up not closed and no errors are visible

[2] Product Tiered Pricing Issue

Steps to reproduce

  1. Create Simple Product
  2. Set Inventory to 100
  3. Set "Qty Uses Decimals" in Advanced Inventory to "Yes"
  4. Set Base Price to 3.99
  5. Open Advanced Pricing tab
  6. Set a Tiered Price for Qty of .5 and price of 2.99
  7. Save

[3] Quantity increment issue

Steps to reproduce

  1. Open Advanced Inventory
  2. Set "Enable Qty Increments" to "Yes"
  3. Set "Qty Increments" to ".5"
  4. Save

Expected result

During each of the above scenarios (2,3), the product should save and allow tiered pricing and qty increments to work with decimal-based inventory

Actual result

Product does not save, admin user is given error stating "Please enter a valid number"

[4] After saving a product with Qty Decimals enabled, Qty Increments and Tier Price Quantity are integer numbers if decimal value was given

Steps to reproduce

  1. Create Simple Product
  2. Set Inventory to 100
  3. Set "Qty Uses Decimals" in Advanced Inventory to "Yes"
  4. Set Base Price to 3.99
  5. Open Advanced Pricing tab
  6. Set a Tiered Price for Qty of 1.5 and price of 2.99
  7. Save
  8. Open Advanced Pricing pop-up

Expected result

Tier price Qty is 1.5

Actual result

Tier price Qty is 1

[5] integer vs decimal numbers affects the front-end in the same way, e.g. mini cart and checkout

Steps to reproduce

Use the same steps from [1] or [4]

Expected result

In cart popup, cart page, checkout cart summary product Qty appear with decimals (if applicable)

Actual result

In cart popup, cart page, checkout cart summary product Qty appear without decimals

@rogyar
Copy link
Contributor

rogyar commented Feb 16, 2018

Please, fix the failed tests. Thanks

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Mar 24, 2018

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ vasilii-b
❌ Vasilii Burlacu


Vasilii Burlacu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.

@vasilii-b vasilii-b force-pushed the issue-12914-mage2.3 branch from f777c86 to 0671a8c Compare March 24, 2018 11:45
@vasilii-b
Copy link
Author

@rogyar Could you please advice on the only remaining failed test ? It says to reduce __construct method parameters to under 10, while it has 10 now.
Thank you!

@rogyar
Copy link
Contributor

rogyar commented Mar 25, 2018

As an option, you can add the stockItemRepository to the helper class (Magento\Bundle\Helper\Data) instead of injecting it directly to the dataProvider.

@vasilii-b
Copy link
Author

Hi @rogyar , can you please advice on the latest failed test ? I see failed tests has nothing related to the work I've done in scope of this PR. Should I still fix them ?

Thank you!

@PieterCappelle
Copy link
Contributor

I'm following this thread, having same issue with one of our clients.

@ishakhsuvarov
Copy link
Contributor

I see failed tests has nothing related to the work I've done in scope of this PR. Should I still fix them ?

This fail relates to the work you have done indirectly. A new dependency added to the class triggered the failure. Usually high object coupling numbers indicates that class has too much responsibilities.

The class, where the test failed, indeed has too much different capabilities to it. You may try refactoring it and extracting some parts out of it.

@vasilii-b vasilii-b changed the title MAGETWO-86164 (Issue 12914) product Qty decimal related issues (both front-end and back-end) [Forwardport] MAGETWO-86164 (Issue 12914) product Qty decimal related issues (both front-end and back-end) Aug 8, 2018
@ishakhsuvarov ishakhsuvarov added this to the Release: 2.3.1 milestone Sep 18, 2018
@sidolov
Copy link
Contributor

sidolov commented Sep 20, 2018

Hi @vasilii-b , will you continue progress with this issue?

@rogyar
Copy link
Contributor

rogyar commented Oct 9, 2018

@vasilii-b. I'm closing this issue due to inactivity. Feel free to reopen it when you decide to proceed. Thank you

@rogyar rogyar closed this Oct 9, 2018
@vasilii-b vasilii-b reopened this Oct 13, 2018
@vasilii-b
Copy link
Author

Hi @rogyar @ishakhsuvarov ,
I've fixed all latest failed tests as well as added requested changes.
Can you please have a look ?

@vasilii-b
Copy link
Author

Hi @ishakhsuvarov, could you please review this PR once again ?
Thank you!

@vasilii-b vasilii-b requested a review from sidolov November 5, 2018 07:27
@vasilii-b vasilii-b added Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Component: Catalog Component: Bundle labels Nov 9, 2018
@vasilii-b vasilii-b added Component: CatalogInventory Area: Frontend Partner: Atwix Pull Request is created by partner Atwix labels Nov 9, 2018
*/
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $collectionFactory,
Data $dataHelper,
StockStateInterface $stockState,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, inject new dependencies according to our Backward Compatible Development Guide

@@ -69,7 +69,9 @@ public function __construct(
}

/**
* {@inheritdoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, revert this changes. Just remove curly braces for static test.

@@ -41,7 +41,8 @@ public function __construct(
}

/**
* {@inheritdoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, revert this changes. Just remove curly braces for static test.

@@ -30,7 +30,8 @@ public function __construct(ArrayManager $arrayManager)
}

/**
* {@inheritdoc}
* @param array $meta
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, revert this changes. Just remove curly braces for static test.

@@ -67,7 +67,8 @@ public function __construct(
}

/**
* {@inheritdoc}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, revert this changes. Just remove curly braces for static test.

@@ -123,7 +130,8 @@ public function __construct(
Data $directoryHelper,
ArrayManager $arrayManager,
$scopeName = '',
GroupSourceInterface $customerGroupSource = null
GroupSourceInterface $customerGroupSource = null,
StockStateInterface $stockState
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, inject new dependencies according to our Backward Compatible Development Guide

* @param AttributeRepositoryInterface|null $attributeRepository
*/
public function __construct(
LocatorInterface $locator,
ArrayManager $arrayManager,
StockStateInterface $stockState,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, inject new dependencies according to our Backward Compatible Development Guide

*
* @return bool
*/
public function isStockQtyDecimal($productId, $scopeId = null): bool;
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not allowed to add new methods to the existing interfaces according to our Backward Compatible Development Guide. Consider creating a new interface with isStockQtyDecimal method

@vasilii-b vasilii-b changed the title [Forwardport] MAGETWO-86164 (Issue 12914) product Qty decimal related issues (both front-end and back-end) Tiered pricing and quantity Increments do not work with decimal inventory MAGETWO-86164 (both front-end and back-end) Nov 13, 2018
@vasilii-b vasilii-b force-pushed the issue-12914-mage2.3 branch 2 times, most recently from 140eb17 to be53c05 Compare November 19, 2018 06:01
@vasilii-b
Copy link
Author

Hi @sidolov, can you please see my latest changes according your requests ? Thank you!

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Thanks for collaboration. Please see the code review notes.

@@ -5,6 +5,9 @@
*/
namespace Magento\Bundle\Helper;

use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the unused use references.

* @param array $meta
* @param array $data
* @param \Magento\Ui\DataProvider\AddFieldToCollectionInterface[] $addFieldStrategies
* @param \Magento\Ui\DataProvider\AddFilterToCollectionInterface[] $addFilterStrategies
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the duplicate parameter declaration

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, that is not a duplicated declaration. They are different.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, my bad, you are absolutely right!

*/
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $collectionFactory,
Data $dataHelper,
StockStateInterface $stockState = null,
Copy link
Member

Choose a reason for hiding this comment

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

Please move the new added dependency to the end of parameters list

/**
* @param LocatorInterface $locator
* @param ArrayManager $arrayManager
* @param StockStateInterface $stockState
Copy link
Member

Choose a reason for hiding this comment

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

Docblock for parameters does not match the actual sequence of parameters

* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

Copy link
Member

Choose a reason for hiding this comment

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

Please enable the strict type mode with declare(strict_types=1); and specify strict types for parameters

*
* @return bool
*/
public function isStockQtyDecimal($productId, $scopeId = null): bool
Copy link
Member

Choose a reason for hiding this comment

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

Please enable strict type mode with declare(strict_types=1);

@sivaschenko sivaschenko self-assigned this Nov 19, 2018
@vasilii-b
Copy link
Author

@sivaschenko can you please take a look on added changes ? Thank you!

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. The code is fine, however, there is an issue with commits. It looks like you made commits under two different accounts, CLA is signed only for one of them, can you please squash your changes under the correct github account

* @param array $meta
* @param array $data
* @param \Magento\Ui\DataProvider\AddFieldToCollectionInterface[] $addFieldStrategies
* @param \Magento\Ui\DataProvider\AddFilterToCollectionInterface[] $addFilterStrategies
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, my bad, you are absolutely right!

@vasilii-b
Copy link
Author

Ok @sivaschenko , I'll do it. Thank you!

@vasilii-b
Copy link
Author

Hi @sivaschenko, all checks are passed now. Thank you!

@magento-engcom-team magento-engcom-team added the partners-contribution Pull Request is created by Magento Partner label Nov 28, 2018
@magento-engcom-team
Copy link
Contributor

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

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

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

Hi @vasilii-b thanks for the contribution. Can you please cover the introduced functionality with MFTF/integration tests.

/**
* StockQtyDecimalInterface
*/
interface StockQtyDecimalInterface
Copy link
Member

Choose a reason for hiding this comment

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

This interface looks more like SPI than API, it's better to place it in the Model namespace

@sivaschenko
Copy link
Member

@vasilii-b closing this pull request due to inactivity. Feel free to reopen it if you'd like to continue progress on it.

@sivaschenko sivaschenko closed this Jan 3, 2019
@vasilii-b
Copy link
Author

@sivaschenko perfect! I'll delete the branch then as I'm full of played ping-pong here: changes are accepted then after a while comes someone else and request changes (and so a couple of times). Moreover, I've spotted that it is a common approach to "kindly force" for integration tests. I'm doing contribution and as far as I understand it - that's what I like to help with.
Seriously, I'm done with it since this PR has more than 1 year from its creation and still playing ping-pong. It's either accepted either deleted at all.

P.S. moving that service from API to SPI folder could be done on Magento side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend Component: Bundle Component: Catalog Component: CatalogInventory Partner: Atwix Pull Request is created by partner Atwix partners-contribution Pull Request is created by Magento Partner Release Line: 2.3 Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants