Skip to content

Commit 46429a4

Browse files
Merge branch '2.4-develop' into 21853
# Conflicts: # lib/internal/Magento/Framework/Mview/View/Subscription.php
2 parents 69cee97 + 91aaeec commit 46429a4

File tree

126 files changed

+2034
-463
lines changed

Some content is hidden

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

126 files changed

+2034
-463
lines changed

app/code/Magento/Analytics/etc/config.xml

+7
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,12 @@
2323
<token/>
2424
</general>
2525
</analytics>
26+
<system>
27+
<media_storage_configuration>
28+
<allowed_resources>
29+
<analytics_folder>analytics</analytics_folder>
30+
</allowed_resources>
31+
</media_storage_configuration>
32+
</system>
2633
</default>
2734
</config>

app/code/Magento/Authorization/Model/Rules.php

+9-23
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,30 @@
2525
class Rules extends \Magento\Framework\Model\AbstractModel
2626
{
2727
/**
28-
* Class constructor
29-
*
30-
* @param \Magento\Framework\Model\Context $context
31-
* @param \Magento\Framework\Registry $registry
32-
* @param \Magento\Authorization\Model\ResourceModel\Rules $resource
33-
* @param \Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection
34-
* @param array $data
35-
*/
36-
public function __construct(
37-
\Magento\Framework\Model\Context $context,
38-
\Magento\Framework\Registry $registry,
39-
\Magento\Authorization\Model\ResourceModel\Rules $resource,
40-
\Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection,
41-
array $data = []
42-
) {
43-
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
44-
}
45-
46-
/**
47-
* Class constructor
48-
*
49-
* @return void
28+
* @inheritdoc
5029
*/
5130
protected function _construct()
5231
{
5332
$this->_init(\Magento\Authorization\Model\ResourceModel\Rules::class);
5433
}
5534

5635
/**
36+
* Obsolete method of update
37+
*
5738
* @return $this
39+
* @deprecated Method was never implemented and used.
5840
*/
5941
public function update()
6042
{
61-
$this->getResource()->update($this);
43+
// phpcs:disable Magento2.Functions.DiscouragedFunction
44+
trigger_error('Method was never implemented and used.', E_USER_DEPRECATED);
45+
6246
return $this;
6347
}
6448

6549
/**
50+
* Save authorization rule relation
51+
*
6652
* @return $this
6753
*/
6854
public function saveRel()

app/code/Magento/AwsS3/Driver/AwsS3.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
304304
* Resolves relative path.
305305
*
306306
* @param string $path Absolute path
307+
* @param bool $fixPath
307308
* @return string Relative path
308309
*/
309310
private function normalizeRelativePath(string $path, bool $fixPath = false): string
@@ -358,7 +359,7 @@ public function isFile($path): bool
358359
return false;
359360
}
360361

361-
$path = $this->normalizeRelativePath($path, true);;
362+
$path = $this->normalizeRelativePath($path, true);
362363

363364
if ($this->adapter->has($path) && ($meta = $this->adapter->getMetadata($path))) {
364365
return ($meta['type'] ?? null) === self::TYPE_FILE;

app/code/Magento/AwsS3/Driver/AwsS3Factory.php

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function createConfigured(
8686
throw new DriverException(__('Bucket and region are required values'));
8787
}
8888

89+
if (!empty($config['http_handler'])) {
90+
$config['http_handler'] = $this->objectManager->create($config['http_handler'])($config);
91+
}
92+
8993
$client = new S3Client($config);
9094
$adapter = new AwsS3Adapter($client, $config['bucket'], $prefix);
9195

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
namespace Magento\AwsS3\Model;
9+
10+
use Aws\Handler\GuzzleV6\GuzzleHandler;
11+
use GuzzleHttp\Client;
12+
use GuzzleHttp\HandlerStack;
13+
use GuzzleHttp\MessageFormatter;
14+
use GuzzleHttp\Middleware;
15+
use Magento\Framework\App\Filesystem\DirectoryList;
16+
use Magento\Framework\Exception\FileSystemException;
17+
use Magento\Framework\Filesystem;
18+
use Monolog\Handler\StreamHandler;
19+
use Monolog\Logger;
20+
21+
final class HttpLoggerHandler
22+
{
23+
/**
24+
* @var Filesystem\Directory\WriteInterface
25+
*/
26+
private $directory;
27+
28+
/**
29+
* @var string
30+
*/
31+
private $file;
32+
33+
/**
34+
* @param Filesystem $filesystem
35+
* @param string $file
36+
* @throws FileSystemException
37+
*/
38+
public function __construct(
39+
Filesystem $filesystem,
40+
$file = 'debug/s3.log'
41+
) {
42+
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
43+
$this->file = $file;
44+
}
45+
46+
public function __invoke()
47+
{
48+
$this->directory->create(pathinfo($this->file, PATHINFO_DIRNAME));
49+
$localStream = $this->directory->getDriver()->fileOpen($this->directory->getAbsolutePath($this->file), 'a');
50+
$streamHandler = new StreamHandler($localStream, Logger::DEBUG, true, null, true);
51+
$logger = new \Monolog\Logger('S3', [$streamHandler]);
52+
$stack = HandlerStack::create();
53+
$stack->push(
54+
Middleware::log(
55+
$logger,
56+
new MessageFormatter('{code}:{method}:{target} {error}')
57+
)
58+
);
59+
return new GuzzleHandler(new Client(['handler' => $stack]));
60+
}
61+
}

app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php

+28-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
namespace Magento\Catalog\Block\Product\View\Options;
1414

15-
use Magento\Catalog\Pricing\Price\BasePrice;
1615
use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
1716
use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface;
1817
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
19+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1920

2021
/**
2122
* Product options section abstract block.
@@ -55,24 +56,42 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
5556
*/
5657
private $calculateCustomOptionCatalogRule;
5758

59+
/**
60+
* @var CalculatorInterface
61+
*/
62+
private $calculator;
63+
64+
/**
65+
* @var PriceCurrencyInterface
66+
*/
67+
private $priceCurrency;
68+
5869
/**
5970
* @param \Magento\Framework\View\Element\Template\Context $context
6071
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
6172
* @param \Magento\Catalog\Helper\Data $catalogData
6273
* @param array $data
6374
* @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule
75+
* @param CalculatorInterface|null $calculator
76+
* @param PriceCurrencyInterface|null $priceCurrency
6477
*/
6578
public function __construct(
6679
\Magento\Framework\View\Element\Template\Context $context,
6780
\Magento\Framework\Pricing\Helper\Data $pricingHelper,
6881
\Magento\Catalog\Helper\Data $catalogData,
6982
array $data = [],
70-
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
83+
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null,
84+
CalculatorInterface $calculator = null,
85+
PriceCurrencyInterface $priceCurrency = null
7186
) {
7287
$this->pricingHelper = $pricingHelper;
7388
$this->_catalogHelper = $catalogData;
7489
$this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule
7590
?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
91+
$this->calculator = $calculator
92+
?? ObjectManager::getInstance()->get(CalculatorInterface::class);
93+
$this->priceCurrency = $priceCurrency
94+
?? ObjectManager::getInstance()->get(PriceCurrencyInterface::class);
7695
parent::__construct($context, $data);
7796
}
7897

@@ -188,7 +207,13 @@ protected function _formatPrice($value, $flag = true)
188207
}
189208

190209
$context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true];
191-
$optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
210+
$optionAmount = $isPercent
211+
? $this->calculator->getAmount(
212+
$this->priceCurrency->roundPrice($value['pricing_value']),
213+
$this->getProduct(),
214+
null,
215+
$context
216+
) : $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
192217
$priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount(
193218
$optionAmount,
194219
$customOptionPrice,

app/code/Magento/Catalog/Model/Product/Image.php

+5-20
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
namespace Magento\Catalog\Model\Product;
77

88
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
9+
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
910
use Magento\Catalog\Model\View\Asset\ImageFactory;
1011
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
1112
use Magento\Framework\App\Filesystem\DirectoryList;
1213
use Magento\Framework\App\ObjectManager;
13-
use Magento\Framework\Exception\FileSystemException;
1414
use Magento\Framework\Image as MagentoImage;
1515
use Magento\Framework\Serialize\SerializerInterface;
16-
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
17-
use Magento\Framework\Filesystem\Driver\File as FilesystemDriver;
1816

1917
/**
2018
* Image operations
@@ -202,11 +200,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
202200
*/
203201
private $serializer;
204202

205-
/**
206-
* @var FilesystemDriver
207-
*/
208-
private $filesystemDriver;
209-
210203
/**
211204
* Constructor
212205
*
@@ -227,7 +220,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
227220
* @param array $data
228221
* @param SerializerInterface $serializer
229222
* @param ParamsBuilder $paramsBuilder
230-
* @param FilesystemDriver $filesystemDriver
231223
* @throws \Magento\Framework\Exception\FileSystemException
232224
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
233225
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
@@ -249,8 +241,7 @@ public function __construct(
249241
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
250242
array $data = [],
251243
SerializerInterface $serializer = null,
252-
ParamsBuilder $paramsBuilder = null,
253-
FilesystemDriver $filesystemDriver = null
244+
ParamsBuilder $paramsBuilder = null
254245
) {
255246
$this->_storeManager = $storeManager;
256247
$this->_catalogProductMediaConfig = $catalogProductMediaConfig;
@@ -265,7 +256,6 @@ public function __construct(
265256
$this->viewAssetPlaceholderFactory = $viewAssetPlaceholderFactory;
266257
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
267258
$this->paramsBuilder = $paramsBuilder ?: ObjectManager::getInstance()->get(ParamsBuilder::class);
268-
$this->filesystemDriver = $filesystemDriver ?: ObjectManager::getInstance()->get(FilesystemDriver::class);
269259
}
270260

271261
/**
@@ -675,12 +665,7 @@ public function getDestinationSubdir()
675665
public function isCached()
676666
{
677667
$path = $this->imageAsset->getPath();
678-
try {
679-
$isCached = is_array($this->loadImageInfoFromCache($path)) || $this->filesystemDriver->isExists($path);
680-
} catch (FileSystemException $e) {
681-
$isCached = false;
682-
}
683-
return $isCached;
668+
return is_array($this->loadImageInfoFromCache($path)) || $this->_mediaDirectory->isExist($path);
684669
}
685670

686671
/**
@@ -952,7 +937,7 @@ private function getImageSize($imagePath)
952937
*/
953938
private function saveImageInfoToCache(array $imageInfo, string $imagePath)
954939
{
955-
$imagePath = $this->cachePrefix . $imagePath;
940+
$imagePath = $this->cachePrefix . $imagePath;
956941
$this->_cacheManager->save(
957942
$this->serializer->serialize($imageInfo),
958943
$imagePath,
@@ -968,7 +953,7 @@ private function saveImageInfoToCache(array $imageInfo, string $imagePath)
968953
*/
969954
private function loadImageInfoFromCache(string $imagePath)
970955
{
971-
$imagePath = $this->cachePrefix . $imagePath;
956+
$imagePath = $this->cachePrefix . $imagePath;
972957
$cacheData = $this->_cacheManager->load($imagePath);
973958
if (!$cacheData) {
974959
return false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontCustomOptionCheckboxByPriceActionGroup">
12+
<annotations>
13+
<description>Validates that the provided price for Custom Option Checkbox is present on the Storefront Product page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="optionTitle" type="string" defaultValue="{{ProductOptionCheckbox.title}}"/>
17+
<argument name="price" type="string" defaultValue="10"/>
18+
</arguments>
19+
20+
<seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(optionTitle, price)}}" stepKey="checkPriceProductOptionCheckbox"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml

+4
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@
577577
<var key="sku" entityType="product" entityKey="sku" />
578578
<requiredEntity type="product_option">ProductOptionDropDownWithLongValuesTitle</requiredEntity>
579579
</entity>
580+
<entity name="productWithCheckbox" type="product">
581+
<var key="sku" entityType="product" entityKey="sku" />
582+
<requiredEntity type="product_option">ProductOptionCheckbox</requiredEntity>
583+
</entity>
580584
<entity name="productWithDropdownOption" type="product">
581585
<var key="sku" entityType="product" entityKey="sku" />
582586
<requiredEntity type="product_option">ProductOptionValueDropdown</requiredEntity>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontCheckCustomOptionPriceDifferentCurrencyTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Custom options"/>
14+
<title value="Check custom option price with different currency"/>
15+
<description value="Check custom option price with different currency on the product page"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-38926"/>
18+
<useCaseId value="MC-30626"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}}" stepKey="setCurrencyAllow"/>
23+
<createData entity="_defaultCategory" stepKey="createCategory"/>
24+
<createData entity="_defaultProduct" stepKey="createProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
<field key="price">10</field>
27+
</createData>
28+
<updateData createDataKey="createProduct" entity="productWithCheckbox" stepKey="updateProductWithOptions"/>
29+
</before>
30+
<after>
31+
<magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}}" stepKey="setCurrencyAllow"/>
32+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
33+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
34+
</after>
35+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductPageOnStorefront">
36+
<argument name="product" value="$createProduct$"/>
37+
</actionGroup>
38+
<actionGroup ref="AssertStorefrontCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionUSD">
39+
<argument name="price" value="12.3"/>
40+
</actionGroup>
41+
<actionGroup ref="StorefrontSwitchCurrencyActionGroup" stepKey="switchEURCurrency">
42+
<argument name="currency" value="EUR"/>
43+
</actionGroup>
44+
<actionGroup ref="AssertStorefrontCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionEUR">
45+
<argument name="price" value="8.7"/>
46+
</actionGroup>
47+
</test>
48+
</tests>

0 commit comments

Comments
 (0)