Skip to content

Commit 8c4fc33

Browse files
authored
Merge branch '2.4-develop' into spartans_pr_18042023
2 parents 2db8941 + 1b6dc48 commit 8c4fc33

File tree

37 files changed

+1074
-174
lines changed

37 files changed

+1074
-174
lines changed

app/code/Magento/Bundle/view/base/templates/product/price/final_price.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
?>
77

88
<?php
9+
// @codingStandardsIgnoreFile
910
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
1011
/** @var \Magento\Bundle\Pricing\Render\FinalPriceBox $block */
1112

@@ -22,7 +23,7 @@ $regularPriceAttributes = [
2223
'display_label' => __('Regular Price'),
2324
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
2425
'include_container' => true,
25-
'skip_adjustments' => true
26+
'skip_adjustments' => false
2627
];
2728
$renderMinimalRegularPrice = $block->renderAmount($minimalRegularPrice, $regularPriceAttributes);
2829
?>

app/code/Magento/Catalog/Pricing/Price/MinimalTierPriceCalculator.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace Magento\Catalog\Pricing\Price;
88

9-
use Magento\Framework\Pricing\SaleableInterface;
109
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
1110
use Magento\Framework\Pricing\Amount\AmountInterface;
11+
use Magento\Framework\Pricing\SaleableInterface;
1212

1313
/**
1414
* As Low As shows minimal value of Tier Prices
@@ -36,18 +36,7 @@ public function __construct(CalculatorInterface $calculator)
3636
*/
3737
public function getValue(SaleableInterface $saleableItem)
3838
{
39-
/** @var TierPrice $price */
40-
$price = $saleableItem->getPriceInfo()->getPrice(TierPrice::PRICE_CODE);
41-
$tierPriceList = $price->getTierPriceList();
42-
43-
$tierPrices = [];
44-
foreach ($tierPriceList as $tierPrice) {
45-
/** @var AmountInterface $price */
46-
$price = $tierPrice['price'];
47-
$tierPrices[] = $price->getValue();
48-
}
49-
50-
return $tierPrices ? min($tierPrices) : null;
39+
return $this->getAmount($saleableItem)?->getValue();
5140
}
5241

5342
/**
@@ -58,10 +47,16 @@ public function getValue(SaleableInterface $saleableItem)
5847
*/
5948
public function getAmount(SaleableInterface $saleableItem)
6049
{
61-
$value = $this->getValue($saleableItem);
50+
$minPrice = null;
51+
/** @var TierPrice $price */
52+
$tierPrice = $saleableItem->getPriceInfo()->getPrice(TierPrice::PRICE_CODE);
53+
$tierPriceList = $tierPrice->getTierPriceList();
54+
55+
if (count($tierPriceList)) {
56+
usort($tierPriceList, fn ($tier1, $tier2) => $tier1['price']->getValue() <=> $tier2['price']->getValue());
57+
$minPrice = array_shift($tierPriceList)['price'];
58+
}
6259

63-
return $value === null
64-
? null
65-
: $this->calculator->getAmount($value, $saleableItem, 'tax');
60+
return $minPrice;
6661
}
6762
}

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
namespace Magento\Catalog\Pricing\Render;
88

9-
use Magento\Catalog\Pricing\Price;
10-
use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;
11-
use Magento\Msrp\Pricing\Price\MsrpPrice;
129
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
13-
use Magento\Framework\View\Element\Template\Context;
14-
use Magento\Framework\Pricing\SaleableInterface;
10+
use Magento\Catalog\Pricing\Price;
11+
use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
1514
use Magento\Framework\Pricing\Price\PriceInterface;
15+
use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;
1616
use Magento\Framework\Pricing\Render\RendererPool;
17-
use Magento\Framework\App\ObjectManager;
18-
use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface;
17+
use Magento\Framework\Pricing\SaleableInterface;
18+
use Magento\Framework\View\Element\Template\Context;
19+
use Magento\Msrp\Pricing\Price\MsrpPrice;
1920

2021
/**
2122
* Class for final_price rendering
@@ -140,7 +141,7 @@ public function renderAmountMinimal()
140141
'display_label' => __('As low as'),
141142
'price_id' => $id,
142143
'include_container' => false,
143-
'skip_adjustments' => true
144+
'skip_adjustments' => false
144145
]
145146
);
146147
}
@@ -183,7 +184,7 @@ public function showMinimalPrice()
183184
public function getCacheKey()
184185
{
185186
return parent::getCacheKey()
186-
. ($this->getData('list_category_page') ? '-list-category-page': '')
187+
. ($this->getData('list_category_page') ? '-list-category-page' : '')
187188
. ($this->getSaleableItem()->getCustomerGroupId() ?? '');
188189
}
189190

app/code/Magento/Catalog/Test/Unit/Pricing/Price/MinimalTierPriceCalculatorTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Test\Unit\Pricing\Price;
99

10+
use Magento\Catalog\Pricing\Price\FinalPrice;
1011
use Magento\Catalog\Pricing\Price\MinimalTierPriceCalculator;
1112
use Magento\Catalog\Pricing\Price\TierPrice;
1213
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
@@ -73,10 +74,10 @@ private function getValueTierPricesExistShouldReturnMinTierPrice()
7374
$notMinPrice = 10;
7475

7576
$minAmount = $this->getMockForAbstractClass(AmountInterface::class);
76-
$minAmount->expects($this->once())->method('getValue')->willReturn($minPrice);
77+
$minAmount->expects($this->atLeastOnce())->method('getValue')->willReturn($minPrice);
7778

7879
$notMinAmount = $this->getMockForAbstractClass(AmountInterface::class);
79-
$notMinAmount->expects($this->once())->method('getValue')->willReturn($notMinPrice);
80+
$notMinAmount->expects($this->atLeastOnce())->method('getValue')->willReturn($notMinPrice);
8081

8182
$tierPriceList = [
8283
[
@@ -89,10 +90,12 @@ private function getValueTierPricesExistShouldReturnMinTierPrice()
8990

9091
$this->price->expects($this->once())->method('getTierPriceList')->willReturn($tierPriceList);
9192

92-
$this->priceInfo->expects($this->once())->method('getPrice')->with(TierPrice::PRICE_CODE)
93-
->willReturn($this->price);
93+
$this->priceInfo->expects($this->atLeastOnce())
94+
->method('getPrice')
95+
->withConsecutive([TierPrice::PRICE_CODE], [FinalPrice::PRICE_CODE])
96+
->willReturnOnConsecutiveCalls($this->price, $notMinAmount);
9497

95-
$this->saleable->expects($this->once())->method('getPriceInfo')->willReturn($this->priceInfo);
98+
$this->saleable->expects($this->atLeastOnce())->method('getPriceInfo')->willReturn($this->priceInfo);
9699
return $minPrice;
97100
}
98101

@@ -107,12 +110,8 @@ public function testGetGetAmountMinTierPriceExistShouldReturnAmountObject()
107110
$minPrice = $this->getValueTierPricesExistShouldReturnMinTierPrice();
108111

109112
$amount = $this->getMockForAbstractClass(AmountInterface::class);
113+
$amount->method('getValue')->willReturn($minPrice);
110114

111-
$this->calculator->expects($this->once())
112-
->method('getAmount')
113-
->with($minPrice, $this->saleable)
114-
->willReturn($amount);
115-
116-
$this->assertSame($amount, $this->object->getAmount($this->saleable));
115+
$this->assertEquals($amount, $this->object->getAmount($this->saleable));
117116
}
118117
}

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ public function testRenderAmountMinimal(): void
339339
$arguments = [
340340
'zone' => 'test_zone',
341341
'list_category_page' => true,
342-
'display_label' => 'As low as',
342+
'display_label' => __('As low as'),
343343
'price_id' => $priceId,
344344
'include_container' => false,
345-
'skip_adjustments' => true
345+
'skip_adjustments' => false
346346
];
347347

348348
$amountRender = $this->createPartialMock(Amount::class, ['toHtml']);

app/code/Magento/Catalog/view/base/templates/product/price/final_price.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
?>
77

88
<?php
9+
// @codingStandardsIgnoreFile
910
/** @var \Magento\Catalog\Pricing\Render\FinalPriceBox $block */
1011

1112
/** ex: \Magento\Catalog\Pricing\Price\RegularPrice */
@@ -34,7 +35,7 @@ $schema = ($block->getZone() == 'item_view') ? true : false;
3435
'price_id' => $block->getPriceId('old-price-' . $idSuffix),
3536
'price_type' => 'oldPrice',
3637
'include_container' => true,
37-
'skip_adjustments' => true
38+
'skip_adjustments' => false
3839
]); ?>
3940
</span>
4041
<?php else :?>

app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private function formatTierPrices(float $productPrice, string $currencyCode, $ti
185185
"discount" => $discount,
186186
"quantity" => $tierPrice->getQty(),
187187
"final_price" => [
188-
"value" => $tierPrice->getValue(),
188+
"value" => $tierPrice->getValue() * $tierPrice->getQty(),
189189
"currency" => $currencyCode
190190
]
191191
];

app/code/Magento/CatalogInventory/Model/Indexer/Stock/CacheCleaner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function clean(array $productIds, callable $reindex)
9090
$this->cacheContext->registerEntities(Product::CACHE_TAG, array_unique($productIds));
9191
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
9292
$categoryIds = $this->getCategoryIdsByProductIds($productIds);
93-
if ($categoryIds){
93+
if ($categoryIds) {
9494
$this->cacheContext->registerEntities(Category::CACHE_TAG, array_unique($categoryIds));
9595
$this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
9696
}
@@ -162,7 +162,7 @@ private function getProductIdsForCacheClean(array $productStatusesBefore, array
162162
}
163163
}
164164

165-
return $productIds;
165+
return array_map('intval', $productIds);
166166
}
167167

168168
/**
@@ -176,7 +176,7 @@ private function getCategoryIdsByProductIds(array $productIds): array
176176
$categoryProductTable = $this->resource->getTableName('catalog_category_product');
177177
$select = $this->getConnection()->select()
178178
->from(['catalog_category_product' => $categoryProductTable], ['category_id'])
179-
->where('product_id IN (?)', $productIds);
179+
->where('product_id IN (?)', $productIds, \Zend_Db::INT_TYPE);
180180

181181
return $this->getConnection()->fetchCol($select);
182182
}

app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/CacheCleanerTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ public function testClean($stockStatusBefore, $stockStatusAfter, $qtyAfter, $sto
122122
$this->selectMock->expects($this->any())
123123
->method('from')
124124
->willReturnSelf();
125-
$this->selectMock->expects($this->any())
126-
->method('where')
127-
->willReturnSelf();
128125
$this->selectMock->expects($this->any())
129126
->method('joinLeft')
130127
->willReturnSelf();
@@ -141,6 +138,21 @@ public function testClean($stockStatusBefore, $stockStatusAfter, $qtyAfter, $sto
141138
['product_id' => $productId, 'stock_status' => $stockStatusAfter, 'qty' => $qtyAfter],
142139
]
143140
);
141+
$this->connectionMock->expects($this->exactly(3))
142+
->method('select')
143+
->willReturn($this->selectMock);
144+
$this->selectMock->expects($this->exactly(7))
145+
->method('where')
146+
->withConsecutive(
147+
['product_id IN (?)'],
148+
['stock_id = ?'],
149+
['website_id = ?'],
150+
['product_id IN (?)'],
151+
['stock_id = ?'],
152+
['website_id = ?'],
153+
['product_id IN (?)', [123], \Zend_Db::INT_TYPE]
154+
)
155+
->willReturnSelf();
144156
$this->connectionMock->expects($this->exactly(1))
145157
->method('fetchCol')
146158
->willReturn([$categoryId]);

app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontNotCalculatedValueInShippingTotalInOrderSummaryActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</annotations>
1515

1616
<arguments>
17-
<argument name="value" defaultValue="Not yet calculated" type="string"/>
17+
<argument name="value" defaultValue="Selected shipping method is not available. Please select another shipping method for this order." type="string"/>
1818
</arguments>
1919
<waitForElementVisible selector="{{CheckoutOrderSummarySection.shippingTotalNotYetCalculated}}" time="30" stepKey="waitForShippingTotalToBeVisible"/>
2020
<see selector="{{CheckoutOrderSummarySection.shippingTotalNotYetCalculated}}" userInput="{{value}}" stepKey="assertShippingTotalIsNotYetCalculated"/>

0 commit comments

Comments
 (0)