Skip to content

Commit 0e20e0b

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-39282' into 2.4-develop-pr47
2 parents 6252c36 + a442c84 commit 0e20e0b

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-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
@@ -379,7 +379,7 @@ public function getTierPrices($product)
379379
if (array_key_exists('website_price', $price)) {
380380
$value = $price['website_price'];
381381
} else {
382-
$value = $price['price'];
382+
$value = $price['price'] ?? 0;
383383
}
384384
$tierPrice->setValue($value);
385385
$tierPrice->setQty($price['price_qty']);

app/code/Magento/Catalog/Test/Unit/Model/Product/Type/PriceTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,40 @@ function () {
263263
);
264264
}
265265
}
266+
267+
/**
268+
* Get tier price with percent value type
269+
*
270+
* @return void
271+
*/
272+
public function testGetPricesWithPercentType(): void
273+
{
274+
$tierPrices = [
275+
0 => [
276+
'record_id' => 0,
277+
'cust_group' => 3200,
278+
'price_qty' => 3,
279+
'website_id' => 0,
280+
'value_type' => 'percent',
281+
'percentage_value' => 10,
282+
],
283+
];
284+
$this->product->setData('tier_price', $tierPrices);
285+
$this->tpFactory->expects($this->any())
286+
->method('create')
287+
->willReturnCallback(
288+
function () {
289+
return $this->objectManagerHelper->getObject(TierPrice::class);
290+
}
291+
);
292+
$tierPriceExtensionMock = $this->getMockBuilder(ProductTierPriceExtensionInterface::class)
293+
->onlyMethods(['getPercentageValue', 'setPercentageValue'])
294+
->getMockForAbstractClass();
295+
$tierPriceExtensionMock->method('getPercentageValue')
296+
->willReturn(50);
297+
$this->tierPriceExtensionFactoryMock->method('create')
298+
->willReturn($tierPriceExtensionMock);
299+
300+
$this->assertInstanceOf(TierPrice::class, $this->model->getTierPrices($this->product)[0]);
301+
}
266302
}

0 commit comments

Comments
 (0)