Skip to content

Commit

Permalink
Merge branch '2.4-develop' of https://github.com/magento-commerce/mag…
Browse files Browse the repository at this point in the history
…ento2ce into ACP2E-3472
  • Loading branch information
aplapana committed Dec 20, 2024
2 parents b7bd82f + d220f78 commit 83aaabc
Show file tree
Hide file tree
Showing 97 changed files with 3,134 additions and 887 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2024 Adobe
* All Rights Reserved.
*/
-->

Expand All @@ -18,8 +18,6 @@
<testCaseId value="MC-115"/>
<group value="Bundle"/>
<group value="cloud"/>
<!-- Excluded from PR builds due to AC-12124 -->
<group value="pr_exclude"/>
</annotations>
<before>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2024 Adobe
* All Rights Reserved.
*/

namespace Magento\Catalog\Controller\Adminhtml\Product\Attribute;
Expand Down Expand Up @@ -269,6 +269,11 @@ public function execute()

unset($data['entity_type_id']);

if (array_key_exists('reset_is-default_option', $data) && $data['reset_is-default_option']) {
unset($data['reset_is-default_option']);
$data['default_value'] = null;
}

$model->addData($data);

if (!$attributeId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
/************************************************************************
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
* ***********************************************************************
*/

declare(strict_types=1);

namespace Magento\Catalog\Model\Product\Image;

use Magento\Catalog\Helper\Image;
use Magento\Catalog\Model\Product\Media\Config;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Encryption\Encryptor;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
Expand All @@ -21,6 +31,11 @@
*/
class RemoveDeletedImagesFromCache
{
/**
* Current hashing algorithm
*/
private const HASH_ALGORITHM = 'md5';

/**
* @var ConfigInterface
*/
Expand Down Expand Up @@ -103,10 +118,10 @@ public function removeDeletedImagesFromCache(array $files): void
unset($imageMiscParams['image_type']);
}

$cacheId = $this->encryptor->hash(
$cacheId = hash(
self::HASH_ALGORITHM,
implode('_', $this->convertImageMiscParamsToReadableFormat
->convertImageMiscParamsToReadableFormat($imageMiscParams)),
Encryptor::HASH_VERSION_MD5
->convertImageMiscParamsToReadableFormat($imageMiscParams))
);

foreach ($files as $filePath) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2024 Adobe
* All Rights Reserved.
*/

namespace Magento\Catalog\Model\Product\Price\Validation;
Expand All @@ -10,10 +10,8 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product\Type;
use Magento\Catalog\Model\ProductIdLocatorInterface;
use Magento\Customer\Api\GroupRepositoryInterface;
use Magento\Directory\Model\Currency;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
use Magento\Store\Api\WebsiteRepositoryInterface;
Expand All @@ -35,21 +33,6 @@ class TierPriceValidator implements ResetAfterRequestInterface
*/
private $productIdLocator;

/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;

/**
* @var FilterBuilder
*/
private $filterBuilder;

/**
* @var GroupRepositoryInterface
*/
private $customerGroupRepository;

/**
* @var WebsiteRepositoryInterface
*/
Expand All @@ -60,13 +43,6 @@ class TierPriceValidator implements ResetAfterRequestInterface
*/
private $validationResult;

/**
* Groups by code cache.
*
* @var array
*/
private $customerGroupsByCode = [];

/**
* @var InvalidSkuProcessor
*/
Expand Down Expand Up @@ -97,6 +73,16 @@ class TierPriceValidator implements ResetAfterRequestInterface
*/
private $productsCacheBySku = [];

/**
* @var ResourceConnection
*/
private $resourceConnection;

/**
* @var array Customer group check cache
*/
private $customerGroupCheck = [];

/**
* @var ScopeConfigInterface
*/
Expand All @@ -106,38 +92,32 @@ class TierPriceValidator implements ResetAfterRequestInterface
* TierPriceValidator constructor.
*
* @param ProductIdLocatorInterface $productIdLocator
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
* @param GroupRepositoryInterface $customerGroupRepository
* @param WebsiteRepositoryInterface $websiteRepository
* @param Result $validationResult
* @param InvalidSkuProcessor $invalidSkuProcessor
* @param ProductRepositoryInterface $productRepository
* @param array $allowedProductTypes [optional]
* @param ResourceConnection|null $resourceConnection
* @param ScopeConfigInterface|null $scopeConfig
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
ProductIdLocatorInterface $productIdLocator,
SearchCriteriaBuilder $searchCriteriaBuilder,
FilterBuilder $filterBuilder,
GroupRepositoryInterface $customerGroupRepository,
WebsiteRepositoryInterface $websiteRepository,
Result $validationResult,
InvalidSkuProcessor $invalidSkuProcessor,
ProductRepositoryInterface $productRepository,
array $allowedProductTypes = [],
?ResourceConnection $resourceConnection = null,
?ScopeConfigInterface $scopeConfig = null
) {
$this->productIdLocator = $productIdLocator;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
$this->customerGroupRepository = $customerGroupRepository;
$this->websiteRepository = $websiteRepository;
$this->validationResult = $validationResult;
$this->invalidSkuProcessor = $invalidSkuProcessor;
$this->productRepository = $productRepository;
$this->allowedProductTypes = $allowedProductTypes;
$this->resourceConnection = $resourceConnection ?: ObjectManager::getInstance()->get(ResourceConnection::class);
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
}

Expand Down Expand Up @@ -504,32 +484,19 @@ private function checkGroup(TierPriceInterface $price, $key, Result $validationR
*/
private function retrieveGroupValue(string $code)
{
if (!isset($this->customerGroupsByCode[$code])) {
$searchCriteria = $this->searchCriteriaBuilder->addFilters(
[
$this->filterBuilder->setField('customer_group_code')->setValue($code)->create()
]
if (!isset($this->customerGroupCheck[$code])) {
$connection = $this->resourceConnection->getConnection();
$select = $connection->select()->from(
$this->resourceConnection->getTableName('customer_group'),
'customer_group_id'
)->where(
'customer_group_code = ?',
$code
);
$items = $this->customerGroupRepository->getList($searchCriteria->create())->getItems();
$item = array_shift($items);

if (!$item) {
$this->customerGroupsByCode[$code] = false;
return false;
}

$itemCode = $item->getCode();
$itemId = $item->getId();

if (strtolower($itemCode) !== $code) {
$this->customerGroupsByCode[$code] = false;
return false;
}

$this->customerGroupsByCode[strtolower($itemCode)] = $itemId;
$this->customerGroupCheck[$code] = $connection->fetchOne($select);
}

return $this->customerGroupsByCode[$code];
return $this->customerGroupCheck[$code];
}

/**
Expand Down Expand Up @@ -576,6 +543,6 @@ private function compareWebsiteValueNewPrice(TierPriceInterface $price, TierPric
*/
public function _resetState(): void
{
$this->customerGroupsByCode = [];
$this->customerGroupCheck = [];
}
}
58 changes: 36 additions & 22 deletions app/code/Magento/Catalog/Model/View/Asset/Image.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
/************************************************************************
* Copyright 2024 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
* ***********************************************************************
*/

namespace Magento\Catalog\Model\View\Asset;
Expand All @@ -11,7 +21,6 @@
use Magento\Catalog\Model\Product\Image\ConvertImageMiscParamsToReadableFormat;
use Magento\Catalog\Model\Product\Media\ConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Encryption\Encryptor;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Asset\ContextInterface;
Expand All @@ -25,6 +34,11 @@
*/
class Image implements LocalInterface
{
/**
* Current hashing algorithm
*/
private const HASH_ALGORITHM = 'md5';

/**
* Image type of image (thumbnail,small_image,image,swatch_image,swatch_thumb)
*
Expand Down Expand Up @@ -96,6 +110,8 @@ class Image implements LocalInterface
* @param CatalogMediaConfig $catalogMediaConfig
* @param StoreManagerInterface $storeManager
* @param ConvertImageMiscParamsToReadableFormat $convertImageMiscParamsToReadableFormat
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
ConfigInterface $mediaConfig,
Expand Down Expand Up @@ -260,29 +276,27 @@ public function getModule()
}

/**
* Retrieve part of path based on misc params
*
* @return string
*/
private function getMiscPath()
{
return $this->encryptor->hash(
implode('_', $this->convertToReadableFormat($this->miscParams)),
Encryptor::HASH_VERSION_MD5
);
}

/**
* Generate path from image info
* Generate path from image info.
*
* @return string
*/
private function getImageInfo()
{
$path = $this->getModule()
. DIRECTORY_SEPARATOR . $this->getMiscPath()
. DIRECTORY_SEPARATOR . $this->getFilePath();
return preg_replace('|\Q'. DIRECTORY_SEPARATOR . '\E+|', DIRECTORY_SEPARATOR, $path);
$data = implode('_', $this->convertToReadableFormat($this->miscParams));

$pathTemplate = $this->getModule()
. DIRECTORY_SEPARATOR . "%s" . DIRECTORY_SEPARATOR
. $this->getFilePath();

/**
* New paths are generated without dependency on
* an encryption key.
*/
return preg_replace(
'|\Q' . DIRECTORY_SEPARATOR . '\E+|',
DIRECTORY_SEPARATOR,
sprintf($pathTemplate, hash(self::HASH_ALGORITHM, $data))
);
}

/**
Expand Down
24 changes: 24 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1580,4 +1580,28 @@
<requiredEntity type="product_option">ProductOptionDropDownFor2</requiredEntity>
<requiredEntity type="product_option">ProductOptionCheckboxFor2</requiredEntity>
</entity>
<entity name="ProductWithTwentyOneTextFieldOptions" type="product">
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionField</requiredEntity>
<requiredEntity type="product_option">ProductOptionField2</requiredEntity>
<requiredEntity type="product_option">ProductOptionField3</requiredEntity>
<requiredEntity type="product_option">ProductOptionField4</requiredEntity>
<requiredEntity type="product_option">ProductOptionField5</requiredEntity>
<requiredEntity type="product_option">ProductOptionField6</requiredEntity>
<requiredEntity type="product_option">ProductOptionField7</requiredEntity>
<requiredEntity type="product_option">ProductOptionField8</requiredEntity>
<requiredEntity type="product_option">ProductOptionField9</requiredEntity>
<requiredEntity type="product_option">ProductOptionField10</requiredEntity>
<requiredEntity type="product_option">ProductOptionField11</requiredEntity>
<requiredEntity type="product_option">ProductOptionField12</requiredEntity>
<requiredEntity type="product_option">ProductOptionField13</requiredEntity>
<requiredEntity type="product_option">ProductOptionField14</requiredEntity>
<requiredEntity type="product_option">ProductOptionField15</requiredEntity>
<requiredEntity type="product_option">ProductOptionField16</requiredEntity>
<requiredEntity type="product_option">ProductOptionField17</requiredEntity>
<requiredEntity type="product_option">ProductOptionField18</requiredEntity>
<requiredEntity type="product_option">ProductOptionField19</requiredEntity>
<requiredEntity type="product_option">ProductOptionField20</requiredEntity>
<requiredEntity type="product_option">ProductOptionField21</requiredEntity>
</entity>
</entities>
Loading

0 comments on commit 83aaabc

Please sign in to comment.