Skip to content

Commit 3d46990

Browse files
committed
Merge remote-tracking branch 'origin/MC-24693' into 2.4-develop-pr144
2 parents 468e1a7 + e4ce701 commit 3d46990

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public function getTierPrice($qty, $product)
298298

299299
$custGroup = $this->_getCustomerGroupId($product);
300300
if ($qty) {
301-
$prevQty = 1;
301+
$prevQty = 0;
302302
$prevPrice = $product->getPrice();
303303
$prevGroup = $allGroupsId;
304304

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Type/PriceTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,17 @@ private function prepareBuyRequest(Product $product): DataObject
222222

223223
return $this->objectManager->create(DataObject::class, ['data' => ['qty' => 1, 'options' => $options]]);
224224
}
225+
226+
/**
227+
* Assert price for different product with decimal qty.
228+
*
229+
* @magentoDataFixture Magento/Catalog/_files/simple_product_with_tier_price_and_decimal_qty.php
230+
* @magentoAppIsolation enabled
231+
* @return void
232+
*/
233+
public function testTierPriceWithDecimalInventory(): void
234+
{
235+
$product = $this->productRepository->get('simple');
236+
$this->assertEquals(2.99, $this->productPrice->getFinalPrice(0.5, $product));
237+
}
225238
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
9+
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Store\Api\WebsiteRepositoryInterface;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
14+
15+
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php');
16+
17+
$objectManager = Bootstrap::getObjectManager();
18+
/** @var ProductRepositoryInterface $productRepository */
19+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
20+
/** @var ProductTierPriceInterfaceFactory $tierPriceFactory */
21+
$tierPriceFactory = $objectManager->get(ProductTierPriceInterfaceFactory::class);
22+
/** @var ProductTierPriceExtensionFactory $tierPriceExtensionAttributesFactory */
23+
$tierPriceExtensionAttributesFactory = $objectManager->get(ProductTierPriceExtensionFactory::class);
24+
$product = $productRepository->get('simple', false, null, true);
25+
$product->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 1, 'is_in_stock' => 1, 'min_sale_qty' => 0.5]);
26+
$adminWebsite = $objectManager->get(WebsiteRepositoryInterface::class)->get('admin');
27+
$tierPrices = $product->getTierPrices() ?? [];
28+
$product->setPrice(3.99);
29+
$tierPriceExtensionAttributes = $tierPriceExtensionAttributesFactory->create()->setWebsiteId($adminWebsite->getId());
30+
$tierPrices[] = $tierPriceFactory->create(
31+
[
32+
'data' => [
33+
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
34+
'qty' => 0.5,
35+
'value' => 2.99
36+
]
37+
]
38+
)->setExtensionAttributes($tierPriceExtensionAttributes);
39+
$product->setTierPrices($tierPrices);
40+
$productRepository->save($product);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
9+
10+
Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php');

0 commit comments

Comments
 (0)