Skip to content

Commit 540c126

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-gl/magento2ce into ACP2E-242
2 parents cac8bbc + 0763e06 commit 540c126

File tree

250 files changed

+27303
-20213
lines changed

Some content is hidden

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

250 files changed

+27303
-20213
lines changed

app/code/Magento/AsynchronousOperations/Model/BulkManagement.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,18 @@ public function __construct(
104104
*/
105105
public function scheduleBulk($bulkUuid, array $operations, $description, $userId = null)
106106
{
107-
$metadata = $this->metadataPool->getMetadata(BulkSummaryInterface::class);
108-
$connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
109-
// save bulk summary and related operations
110-
$connection->beginTransaction();
111107
$userType = $this->userContext->getUserType();
112108
if ($userType === null) {
113109
$userType = UserContextInterface::USER_TYPE_ADMIN;
114110
}
111+
if ($userId === null && $userType === UserContextInterface::USER_TYPE_ADMIN) {
112+
$userId = $this->userContext->getUserId();
113+
}
114+
115+
$metadata = $this->metadataPool->getMetadata(BulkSummaryInterface::class);
116+
$connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
117+
// save bulk summary and related operations
118+
$connection->beginTransaction();
115119
try {
116120
/** @var BulkSummaryInterface $bulkSummary */
117121
$bulkSummary = $this->bulkSummaryFactory->create();

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,17 @@ private function applyBundlePrice($priceTable): void
822822
]
823823
);
824824

825-
$this->tableMaintainer->insertFromSelect($select, $priceTable->getTableName(), []);
825+
$this->tableMaintainer->insertFromSelect($select, $priceTable->getTableName(), [
826+
"entity_id",
827+
"customer_group_id",
828+
"website_id",
829+
"tax_class_id",
830+
"price",
831+
"final_price",
832+
"min_price",
833+
"max_price",
834+
"tier_price",
835+
]);
826836
}
827837

828838
/**

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price/DisabledProductOptionPriceModifier.php

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,22 @@ class DisabledProductOptionPriceModifier implements PriceModifierInterface
3434
/**
3535
* @var array
3636
*/
37-
private $isBundle = [];
37+
private $websiteIdsOfProduct = [];
3838

3939
/**
40-
* @var array
40+
* @var BundleSelection
4141
*/
42-
private $websiteIdsOfProduct = [];
42+
private BundleSelection $bundleSelection;
43+
44+
/**
45+
* @var Config
46+
*/
47+
private Config $config;
48+
49+
/**
50+
* @var MetadataPool
51+
*/
52+
private MetadataPool $metadataPool;
4353

4454
/**
4555
* @param ResourceConnection $resourceConnection
@@ -72,11 +82,8 @@ public function __construct(
7282
*/
7383
public function modifyPrice(IndexTableStructure $priceTable, array $entityIds = []) : void
7484
{
75-
foreach ($entityIds as $entityId) {
85+
foreach ($this->getBundleIds($entityIds) as $entityId) {
7686
$entityId = (int) $entityId;
77-
if (!$this->isBundle($entityId)) {
78-
continue;
79-
}
8087
foreach ($this->getWebsiteIdsOfProduct($entityId) as $websiteId) {
8188
$productIdsDisabledRequired = $this->selectionProductsDisabledRequired
8289
->getChildProductIds($entityId, (int)$websiteId);
@@ -118,24 +125,24 @@ private function getWebsiteIdsOfProduct(int $entityId): array
118125
}
119126

120127
/**
121-
* Is product bundle
128+
* Get Bundle Ids
122129
*
123-
* @param int $entityId
124-
* @return bool
130+
* @param array $entityIds
131+
* @return \Traversable
125132
*/
126-
private function isBundle(int $entityId): bool
133+
private function getBundleIds(array $entityIds): \Traversable
127134
{
128-
if (isset($this->isBundle[$entityId])) {
129-
return $this->isBundle[$entityId];
130-
}
131135
$connection = $this->resourceConnection->getConnection('indexer');
132136
$select = $connection->select();
133137
$select->from(
134138
['cpe' => $this->resourceConnection->getTableName('catalog_product_entity')],
135-
['type_id']
136-
)->where('cpe.entity_id = ?', $entityId);
137-
$typeId = $connection->fetchOne($select);
138-
$this->isBundle[$entityId] = $typeId === Type::TYPE_BUNDLE;
139-
return $this->isBundle[$entityId];
139+
['entity_id']
140+
)->where('cpe.entity_id in ( ? )', !empty($entityIds) ? $entityIds : [0], \Zend_Db::INT_TYPE)
141+
->where('type_id = ?', Type::TYPE_BUNDLE);
142+
143+
$statement = $select->query();
144+
while ($id = $statement->fetchColumn()) {
145+
yield $id;
146+
}
140147
}
141148
}

app/code/Magento/BundleGraphQl/Model/Resolver/Order/Item/BundleOptions.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class BundleOptions implements ResolverInterface
3030
private const OPTION_TYPE = 'bundle';
3131

3232
/**
33-
* Serializer
34-
*
3533
* @var Json
3634
*/
3735
private $serializer;
@@ -148,7 +146,7 @@ private function formatBundleOptionItems(
148146
$optionDetails = [
149147
self::OPTION_TYPE,
150148
$bundleChildAttributes['option_id'],
151-
implode(',', $options),
149+
is_array($options) ? implode(',', $options) : $options,
152150
(int) $childOrderItemOptions['info_buyRequest']['qty']
153151
];
154152

app/code/Magento/Captcha/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"magento/module-authorization": "*",
1616
"laminas/laminas-captcha": "^2.11.0",
1717
"laminas/laminas-db": "^2.13.4",
18-
"laminas/laminas-session": "^2.12.0"
18+
"laminas/laminas-session": "^2.12.1"
1919
},
2020
"type": "magento2-module",
2121
"license": [

app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Catalog\Model\Attribute;
88

9+
use Magento\Catalog\Model\AbstractModel;
10+
use Magento\Framework\DataObject;
911
use Magento\Framework\EntityManager\MetadataPool;
1012
use Magento\Eav\Api\AttributeRepositoryInterface as AttributeRepository;
1113
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -15,7 +17,6 @@
1517
use Magento\Framework\App\ResourceConnection;
1618

1719
/**
18-
* Class ScopeOverriddenValue
1920
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2021
*/
2122
class ScopeOverriddenValue
@@ -76,7 +77,7 @@ public function __construct(
7677
* Whether attribute value is overridden in specific store
7778
*
7879
* @param string $entityType
79-
* @param \Magento\Catalog\Model\AbstractModel $entity
80+
* @param AbstractModel $entity
8081
* @param string $attributeCode
8182
* @param int|string $storeId
8283
* @return bool
@@ -86,39 +87,41 @@ public function containsValue($entityType, $entity, $attributeCode, $storeId)
8687
if ((int)$storeId === Store::DEFAULT_STORE_ID) {
8788
return false;
8889
}
89-
if (!isset($this->attributesValues[$storeId])) {
90+
$values = $this->getAttributesValues($entityType, $entity);
91+
92+
if (!isset($values[$storeId])) {
9093
$this->initAttributeValues($entityType, $entity, (int)$storeId);
94+
$values = $this->getAttributesValues($entityType, $entity);
9195
}
9296

93-
return isset($this->attributesValues[$storeId])
94-
&& array_key_exists($attributeCode, $this->attributesValues[$storeId]);
97+
return isset($values[$storeId]) && array_key_exists($attributeCode, $values[$storeId]);
9598
}
9699

97100
/**
98101
* Get attribute default values
99102
*
100103
* @param string $entityType
101-
* @param \Magento\Catalog\Model\AbstractModel $entity
104+
* @param AbstractModel $entity
102105
* @return array
103106
*
104107
* @deprecated 101.0.0
105108
*/
106109
public function getDefaultValues($entityType, $entity)
107110
{
108-
if ($this->attributesValues === null) {
111+
$values = $this->getAttributesValues($entityType, $entity);
112+
if (!isset($values[Store::DEFAULT_STORE_ID])) {
109113
$this->initAttributeValues($entityType, $entity, (int)$entity->getStoreId());
114+
$values = $this->getAttributesValues($entityType, $entity);
110115
}
111116

112-
return isset($this->attributesValues[Store::DEFAULT_STORE_ID])
113-
? $this->attributesValues[Store::DEFAULT_STORE_ID]
114-
: [];
117+
return $values[Store::DEFAULT_STORE_ID] ?? [];
115118
}
116119

117120
/**
118121
* Init attribute values.
119122
*
120123
* @param string $entityType
121-
* @param \Magento\Catalog\Model\AbstractModel $entity
124+
* @param AbstractModel $entity
122125
* @param int $storeId
123126
* @throws \Magento\Framework\Exception\LocalizedException
124127
* @return void
@@ -129,6 +132,7 @@ private function initAttributeValues($entityType, $entity, $storeId)
129132
/** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute */
130133
$attributeTables = [];
131134
if ($metadata->getEavEntityType()) {
135+
$entityId = $entity->getData($metadata->getLinkField());
132136
foreach ($this->getAttributes($entityType) as $attribute) {
133137
if (!$attribute->isStatic()) {
134138
$attributeTables[$attribute->getBackend()->getTable()][] = $attribute->getAttributeId();
@@ -147,7 +151,7 @@ private function initAttributeValues($entityType, $entity, $storeId)
147151
'a.attribute_id = t.attribute_id',
148152
['attribute_code' => 'a.attribute_code']
149153
)
150-
->where($metadata->getLinkField() . ' = ?', $entity->getData($metadata->getLinkField()))
154+
->where($metadata->getLinkField() . ' = ?', $entityId)
151155
->where('t.attribute_id IN (?)', $attributeCodes)
152156
->where('t.store_id IN (?)', $storeIds);
153157
$selects[] = $select;
@@ -158,9 +162,12 @@ private function initAttributeValues($entityType, $entity, $storeId)
158162
\Magento\Framework\DB\Select::SQL_UNION_ALL
159163
);
160164
$attributes = $metadata->getEntityConnection()->fetchAll((string)$unionSelect);
165+
$values = array_fill_keys($storeIds, []);
161166
foreach ($attributes as $attribute) {
162-
$this->attributesValues[$attribute['store_id']][$attribute['attribute_code']] = $attribute['value'];
167+
$values[$attribute['store_id']][$attribute['attribute_code']] = $attribute['value'];
163168
}
169+
$values += $this->getAttributesValues($entityType, $entity);
170+
$this->setAttributesValues($entityType, $entity, $values);
164171
}
165172
}
166173

@@ -187,4 +194,52 @@ private function getAttributes($entityType)
187194
);
188195
return $searchResult->getItems();
189196
}
197+
198+
/**
199+
* Clear entity attributes values cache
200+
*
201+
* @param string $entityType
202+
* @param DataObject $entity
203+
* @return void
204+
* @throws \Exception
205+
*/
206+
public function clearAttributesValues(string $entityType, DataObject $entity): void
207+
{
208+
if (isset($this->attributesValues[$entityType])) {
209+
$metadata = $this->metadataPool->getMetadata($entityType);
210+
$entityId = $entity->getData($metadata->getLinkField());
211+
unset($this->attributesValues[$entityType][$entityId]);
212+
}
213+
}
214+
215+
/**
216+
* Get entity attributes values from cache
217+
*
218+
* @param string $entityType
219+
* @param DataObject $entity
220+
* @return array
221+
* @throws \Exception
222+
*/
223+
private function getAttributesValues(string $entityType, DataObject $entity): array
224+
{
225+
$metadata = $this->metadataPool->getMetadata($entityType);
226+
$entityId = $entity->getData($metadata->getLinkField());
227+
return $this->attributesValues[$entityType][$entityId] ?? [];
228+
}
229+
230+
/**
231+
* Set entity attributes values into cache
232+
*
233+
* @param string $entityType
234+
* @param DataObject $entity
235+
* @param array $values
236+
* @return void
237+
* @throws \Exception
238+
*/
239+
private function setAttributesValues(string $entityType, DataObject $entity, array $values): void
240+
{
241+
$metadata = $this->metadataPool->getMetadata($entityType);
242+
$entityId = $entity->getData($metadata->getLinkField());
243+
$this->attributesValues[$entityType][$entityId] = $values;
244+
}
190245
}

app/code/Magento/Catalog/Model/Indexer/Product/Price.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public function __construct(
6666
public function execute($ids)
6767
{
6868
$this->_productPriceIndexerRows->execute($ids);
69-
$this->cacheContext->registerEntities(ProductModel::CACHE_TAG, $ids);
7069
}
7170

7271
/**

app/code/Magento/Catalog/Model/Indexer/Product/Price/AbstractAction.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ abstract class AbstractAction
6161
protected $_storeManager;
6262

6363
/**
64-
* Currency factory
6564
*
6665
* @var CurrencyFactory
6766
*/
@@ -83,7 +82,6 @@ abstract class AbstractAction
8382
protected $_catalogProductType;
8483

8584
/**
86-
* Indexer price factory
8785
*
8886
* @var Factory
8987
*/
@@ -343,16 +341,15 @@ protected function _getIndexer($productTypeId)
343341
*/
344342
protected function _insertFromTable($sourceTable, $destTable, $where = null)
345343
{
346-
$sourceColumns = array_keys($this->getConnection()->describeTable($sourceTable));
347-
$targetColumns = array_keys($this->getConnection()->describeTable($destTable));
348-
$select = $this->getConnection()->select()->from($sourceTable, $sourceColumns);
344+
$columns = array_keys($this->getConnection()->describeTable($destTable));
345+
$select = $this->getConnection()->select()->from($sourceTable, $columns);
349346
if ($where) {
350347
$select->where($where);
351348
}
352349
$query = $this->getConnection()->insertFromSelect(
353350
$select,
354351
$destTable,
355-
$targetColumns,
352+
$columns,
356353
AdapterInterface::INSERT_ON_DUPLICATE
357354
);
358355
$this->getConnection()->query($query);

0 commit comments

Comments
 (0)