Skip to content

Commit 31364ca

Browse files
committed
Merge remote-tracking branch 'perf/application-server-part2' into ACPT-1052-part4
2 parents 1f01980 + 405eb07 commit 31364ca

File tree

48 files changed

+1157
-207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1157
-207
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/Model/Indexer/Category/Product/AbstractAction.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\DB\Query\Generator as QueryGenerator;
1414
use Magento\Framework\DB\Select;
1515
use Magento\Framework\EntityManager\MetadataPool;
16+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1617
use Magento\Store\Api\Data\StoreInterface;
1718
use Magento\Store\Model\Store;
1819

@@ -25,7 +26,7 @@
2526
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2627
* @since 100.0.2
2728
*/
28-
abstract class AbstractAction
29+
abstract class AbstractAction implements ResetAfterRequestInterface
2930
{
3031
/**
3132
* Chunk size
@@ -156,6 +157,20 @@ public function __construct(
156157
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
157158
}
158159

160+
/**
161+
* @inheritDoc
162+
*/
163+
public function _resetState(): void
164+
{
165+
$this->nonAnchorSelects = [];
166+
$this->anchorSelects = [];
167+
$this->productsSelects = [];
168+
$this->categoryPath = [];
169+
$this->useTempTable = true;
170+
$this->tempTreeIndexTableName = null;
171+
$this->currentStore = null;
172+
}
173+
159174
/**
160175
* Run full reindex
161176
*

app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
1111
use Magento\Catalog\Model\Product\Attribute\Backend\Price;
1212
use Magento\Customer\Api\GroupManagementInterface;
13+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1314

1415
/**
1516
* Catalog product abstract group price backend attribute model
1617
*
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1819
*/
19-
abstract class AbstractGroupPrice extends Price
20+
abstract class AbstractGroupPrice extends Price implements ResetAfterRequestInterface
2021
{
2122
/**
2223
* @var \Magento\Framework\EntityManager\MetadataPool
@@ -26,7 +27,7 @@ abstract class AbstractGroupPrice extends Price
2627
/**
2728
* Website currency codes and rates
2829
*
29-
* @var array
30+
* @var array|null
3031
*/
3132
protected $_rates;
3233

@@ -39,8 +40,6 @@ abstract class AbstractGroupPrice extends Price
3940
abstract protected function _getDuplicateErrorMessage();
4041

4142
/**
42-
* Catalog product type
43-
*
4443
* @var \Magento\Catalog\Model\Product\Type
4544
*/
4645
protected $_catalogProductType;
@@ -82,6 +81,14 @@ public function __construct(
8281
);
8382
}
8483

84+
/**
85+
* @inheritdoc
86+
*/
87+
public function _resetState() : void
88+
{
89+
$this->_rates = null;
90+
}
91+
8592
/**
8693
* Retrieve websites currency rates and base currency codes
8794
*

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
@@ -186,7 +186,7 @@ private function formatTierPrices(float $productPrice, string $currencyCode, $ti
186186
"discount" => $discount,
187187
"quantity" => $tierPrice->getQty(),
188188
"final_price" => [
189-
"value" => $tierPrice->getValue(),
189+
"value" => $tierPrice->getValue() * $tierPrice->getQty(),
190190
"currency" => $currencyCode
191191
]
192192
];

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
}

0 commit comments

Comments
 (0)