Skip to content

Commit e457c5e

Browse files
authored
Merge pull request #10047 from adobe-commerce-tier-4/PR_2025_08_25_muntianu
[Support Tier-4 muntianu] 08-25-2025 Regular delivery of bugfixes and improvements
2 parents 657f983 + 6645d43 commit e457c5e

File tree

26 files changed

+1428
-67
lines changed

26 files changed

+1428
-67
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class SearchCriteriaBuilder
3838
* @param RequestDataBuilder $localData
3939
* @param SearchCriteriaResolverFactory $criteriaResolverFactory
4040
* @param ArgumentApplierPool $argumentApplierPool
41+
* @param array $partialSearchAnalyzers
4142
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
4243
*/
4344
public function __construct(
@@ -51,6 +52,7 @@ public function __construct(
5152
private readonly RequestDataBuilder $localData,
5253
private readonly SearchCriteriaResolverFactory $criteriaResolverFactory,
5354
private readonly ArgumentApplierPool $argumentApplierPool,
55+
private readonly array $partialSearchAnalyzers = []
5456
) {
5557
}
5658

@@ -117,6 +119,10 @@ private function updateMatchTypeRequestConfig(string $requestName, array $partia
117119
foreach ($query['match'] ?? [] as $index => $matchItem) {
118120
if (in_array($matchItem['field'] ?? null, $partialMatchFilters, true)) {
119121
$data['queries'][$queryName]['match'][$index]['matchCondition'] = 'match_phrase_prefix';
122+
if (array_key_exists($matchItem['field'], $this->partialSearchAnalyzers)) {
123+
$data['queries'][$queryName]['match'][$index]['analyzer']
124+
= $this->partialSearchAnalyzers[$matchItem['field']];
125+
}
120126
}
121127
}
122128
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Discount.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ private function getPriceDifferenceAsValue(float $regularPrice, float $finalPric
7272
*/
7373
private function getPriceDifferenceAsPercent(float $regularPrice, float $finalPrice): float
7474
{
75-
$difference = $this->getPriceDifferenceAsValue($regularPrice, $finalPrice);
75+
$difference = $regularPrice - $finalPrice;
76+
if ($difference <= $this->zeroThreshold) {
77+
return 0;
78+
}
7679

7780
if ($difference <= $this->zeroThreshold || $regularPrice <= $this->zeroThreshold) {
7881
return 0;

app/code/Magento/CatalogGraphQl/etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,12 @@
150150
</argument>
151151
</arguments>
152152
</type>
153+
154+
<type name="Magento\CatalogGraphQl\DataProvider\Product\SearchCriteriaBuilder">
155+
<arguments>
156+
<argument name="partialSearchAnalyzers" xsi:type="array">
157+
<item name="name" xsi:type="string">prefix_search</item>
158+
</argument>
159+
</arguments>
160+
</type>
153161
</config>

app/code/Magento/CatalogRule/Model/Indexer/ProductPriceCalculator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright 2017 Adobe
44
* All Rights Reserved.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\CatalogRule\Model\Indexer;
89

@@ -28,7 +29,7 @@ public function __construct(\Magento\Framework\Pricing\PriceCurrencyInterface $p
2829
* Calculates product price.
2930
*
3031
* @param array $ruleData
31-
* @param null $productData
32+
* @param array|null $productData
3233
* @return float
3334
*/
3435
public function calculate($ruleData, $productData = null)
@@ -56,6 +57,6 @@ public function calculate($ruleData, $productData = null)
5657
$productPrice = 0;
5758
}
5859

59-
return $this->priceCurrency->round($productPrice);
60+
return $this->priceCurrency->roundPrice($productPrice, 4);
6061
}
6162
}

app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
use Magento\Store\Model\StoreManagerInterface;
1919

2020
/**
21-
* Class CatalogRulePrice
22-
*
2321
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2422
*/
2523
class CatalogRulePrice extends AbstractPrice implements BasePriceProviderInterface
2624
{
2725
/**
2826
* Price type identifier string
2927
*/
30-
const PRICE_CODE = 'catalog_rule_price';
28+
public const PRICE_CODE = 'catalog_rule_price';
3129

3230
/**
3331
* @var TimezoneInterface
@@ -97,7 +95,7 @@ public function getValue()
9795
$this->value = $this->value ? (float)$this->value : false;
9896
}
9997
if ($this->value) {
100-
$this->value = $this->priceCurrency->convertAndRound($this->value);
98+
$this->value = $this->priceCurrency->convertAndRound($this->value, null, null, 4);
10199
}
102100
}
103101

app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ProductPriceCalculatorTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
declare(strict_types=1);
77

8-
98
namespace Magento\CatalogRule\Test\Unit\Model\Indexer;
109

1110
use Magento\CatalogRule\Model\Indexer\ProductPriceCalculator;
@@ -29,6 +28,7 @@ protected function setUp(): void
2928
{
3029
$this->priceCurrencyMock = $this->getMockBuilder(PriceCurrencyInterface::class)
3130
->disableOriginalConstructor()
31+
->addMethods(['roundPrice'])
3232
->getMockForAbstractClass();
3333
$this->model = new ProductPriceCalculator($this->priceCurrencyMock);
3434
}
@@ -44,8 +44,8 @@ public function testCalculateToFixedPrice()
4444
$productData = ['rule_price' => $rulePrice];
4545

4646
$this->priceCurrencyMock->expects($this->once())
47-
->method('round')
48-
->with($actionAmount)
47+
->method('roundPrice')
48+
->with($actionAmount, 4)
4949
->willReturn($actionAmount);
5050

5151
$this->assertEquals($actionAmount, $this->model->calculate($ruleData, $productData));
@@ -63,8 +63,8 @@ public function testCalculateToPercentPrice()
6363
$productData = ['rule_price' => $rulePrice];
6464

6565
$this->priceCurrencyMock->expects($this->once())
66-
->method('round')
67-
->with($expectedPrice)
66+
->method('roundPrice')
67+
->with($expectedPrice, 4)
6868
->willReturn($expectedPrice);
6969

7070
$this->assertEquals($expectedPrice, $this->model->calculate($ruleData, $productData));
@@ -82,8 +82,8 @@ public function testCalculateByFixedPrice()
8282
$productData = ['rule_price' => $rulePrice];
8383

8484
$this->priceCurrencyMock->expects($this->once())
85-
->method('round')
86-
->with($expectedPrice)
85+
->method('roundPrice')
86+
->with($expectedPrice, 4)
8787
->willReturn($expectedPrice);
8888

8989
$this->assertEquals($expectedPrice, $this->model->calculate($ruleData, $productData));
@@ -101,8 +101,8 @@ public function testCalculateByPercentPrice()
101101
$productData = ['rule_price' => $rulePrice];
102102

103103
$this->priceCurrencyMock->expects($this->once())
104-
->method('round')
105-
->with($expectedPrice)
104+
->method('roundPrice')
105+
->with($expectedPrice, 4)
106106
->willReturn($expectedPrice);
107107

108108
$this->assertEquals($expectedPrice, $this->model->calculate($ruleData, $productData));

app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testGetValue()
142142
->willReturn($productId);
143143
$this->priceCurrencyMock->expects($this->once())
144144
->method('convertAndRound')
145-
->with($catalogRulePrice)
145+
->with($catalogRulePrice, null, null, 4)
146146
->willReturn($convertedPrice);
147147

148148
$this->assertEquals($convertedPrice, $this->object->getValue());
@@ -155,7 +155,7 @@ public function testGetValueFromData()
155155

156156
$this->priceCurrencyMock->expects($this->any())
157157
->method('convertAndRound')
158-
->with($catalogRulePrice)
158+
->with($catalogRulePrice, null, null, 4)
159159
->willReturn($convertedPrice);
160160

161161
$this->saleableItemMock->expects($this->once())->method('hasData')

app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ protected function addGlobalAttribute(
178178
$storeId = $connection->getIfNullSql($alias . '.store_id', $this->storeManager->getStore()->getId());
179179
$linkField = $attribute->getEntity()->getLinkField();
180180

181-
$collection->getSelect()->join(
181+
$collection->getSelect()->joinLeft(
182182
[$alias => $collection->getTable($attribute->getBackendTable())],
183183
"($alias.$linkField = e.$linkField) AND ($alias.store_id = $storeId)" .
184184
" AND ($alias.attribute_id = {$attribute->getId()})",

app/code/Magento/Csp/Plugin/GenerateAssetIntegrity.php

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2017 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -88,4 +88,76 @@ public function afterCreateRequireJsConfigAsset(
8888

8989
return $result;
9090
}
91+
92+
/**
93+
* Generates integrity for RequireJs mixins asset.
94+
*
95+
* @param FileManager $subject
96+
* @param File $result
97+
*
98+
* @return File
99+
*
100+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
101+
*/
102+
public function afterCreateRequireJsMixinsAsset(
103+
FileManager $subject,
104+
File $result
105+
): File {
106+
if (PHP_SAPI === 'cli') {
107+
$this->generateHash($result);
108+
}
109+
110+
return $result;
111+
}
112+
113+
/**
114+
* Generates integrity for static JS asset.
115+
*
116+
* @param FileManager $subject
117+
* @param File|false $result
118+
*
119+
* @return File|false
120+
*
121+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
122+
*/
123+
public function afterCreateStaticJsAsset(
124+
FileManager $subject,
125+
mixed $result
126+
): mixed {
127+
if ($result !== false && PHP_SAPI === 'cli') {
128+
$this->generateHash($result);
129+
}
130+
131+
return $result;
132+
}
133+
134+
/**
135+
* Generates hash for the given file result if it matches the supported content types.
136+
*
137+
* @param File $result
138+
* @return void
139+
*/
140+
private function generateHash(File $result): void
141+
{
142+
if (in_array($result->getContentType(), self::CONTENT_TYPES)) {
143+
try {
144+
$content = $result->getContent();
145+
} catch (\Exception $e) {
146+
$content = null;
147+
}
148+
$path = $result->getPath();
149+
150+
if ($content !== null) {
151+
$integrity = $this->integrityFactory->create(
152+
[
153+
"data" => [
154+
'hash' => $this->hashGenerator->generate($content),
155+
'path' => $path
156+
]
157+
]
158+
);
159+
$this->integrityCollector->collect($integrity);
160+
}
161+
}
162+
}
91163
}

0 commit comments

Comments
 (0)