Skip to content

Commit e0ce41c

Browse files
committed
Merge branch '2.4-develop' of github.com:magento-commerce/magento2ce into PWA-2565
2 parents 2725cae + 0763e06 commit e0ce41c

File tree

121 files changed

+20951
-19507
lines changed

Some content is hidden

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

121 files changed

+20951
-19507
lines changed

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/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);

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
*/
66
namespace Magento\Catalog\Model\Indexer\Product\Price\Action;
77

8-
use Magento\Directory\Model\CurrencyFactory;
98
use Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory;
109
use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
10+
use Magento\Catalog\Model\Product;
1111
use Magento\Catalog\Model\Product\Type;
1212
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice;
1313
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Factory;
1414
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\TierPrice;
15+
use Magento\Directory\Model\CurrencyFactory;
1516
use Magento\Framework\App\Config\ScopeConfigInterface;
17+
use Magento\Framework\App\ObjectManager;
18+
use Magento\Framework\Indexer\CacheContext;
1619
use Magento\Framework\Stdlib\DateTime;
1720
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1821
use Magento\Store\Model\StoreManagerInterface;
@@ -34,6 +37,11 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction
3437
*/
3538
private $batchSize;
3639

40+
/**
41+
* @var CacheContext
42+
*/
43+
private CacheContext $cacheContext;
44+
3745
/**
3846
* @param ScopeConfigInterface $config
3947
* @param StoreManagerInterface $storeManager
@@ -47,6 +55,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Product\Price\AbstractAction
4755
* @param DimensionCollectionFactory|null $dimensionCollectionFactory
4856
* @param TableMaintainer|null $tableMaintainer
4957
* @param int|null $batchSize
58+
* @param CacheContext|null $cacheContext
5059
* @SuppressWarnings(PHPMD.NPathComplexity) Added to backward compatibility with abstract class
5160
* @SuppressWarnings(PHPMD.CyclomaticComplexity) Added to backward compatibility with abstract class
5261
* @SuppressWarnings(PHPMD.ExcessiveParameterList) Added to backward compatibility with abstract class
@@ -63,7 +72,8 @@ public function __construct(
6372
TierPrice $tierPriceIndexResource = null,
6473
DimensionCollectionFactory $dimensionCollectionFactory = null,
6574
TableMaintainer $tableMaintainer = null,
66-
?int $batchSize = null
75+
?int $batchSize = null,
76+
CacheContext $cacheContext = null
6777
) {
6878
parent::__construct(
6979
$config,
@@ -79,6 +89,7 @@ public function __construct(
7989
$tableMaintainer
8090
);
8191
$this->batchSize = $batchSize ?? self::BATCH_SIZE;
92+
$this->cacheContext = $cacheContext ?? ObjectManager::getInstance()->get(CacheContext::class);
8293
}
8394

8495
/**
@@ -101,7 +112,7 @@ public function execute($ids)
101112
$currentBatch[] = $id;
102113
if (++$i === $this->batchSize) {
103114
try {
104-
$this->_reindexRows($currentBatch);
115+
$this->cacheContext->registerEntities(Product::CACHE_TAG, $this->_reindexRows($currentBatch));
105116
} catch (\Exception $e) {
106117
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e);
107118
}
@@ -112,7 +123,7 @@ public function execute($ids)
112123

113124
if (!empty($currentBatch)) {
114125
try {
115-
$this->_reindexRows($currentBatch);
126+
$this->cacheContext->registerEntities(Product::CACHE_TAG, $this->_reindexRows($currentBatch));
116127
} catch (\Exception $e) {
117128
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e);
118129
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Decimal.php

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
namespace Magento\Catalog\Model\ResourceModel\Product\Indexer\Eav;
77

88
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Framework\DB\Select;
10+
use Magento\Store\Model\Store;
11+
use Zend_Db;
912

1013
/**
1114
* Catalog Product Eav Decimal Attributes Indexer resource model
@@ -46,37 +49,72 @@ protected function _prepareIndex($entityIds = null, $attributeId = null)
4649
return $this;
4750
}
4851

49-
$productIdField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
50-
$productValueExpression = $connection->getCheckSql('pds.value_id > 0', 'pds.value', 'pdd.value');
52+
$select = $connection->select()
53+
->union(
54+
[
55+
$this->getSelect($attrIds, $entityIds),
56+
$this->getSelect($attrIds, $entityIds, true)
57+
]
58+
);
5159

52-
$select = $connection->select()->from(
53-
['pdd' => $this->getTable('catalog_product_entity_decimal')],
54-
[]
55-
)->join(
56-
['cs' => $this->getTable('store')],
57-
'',
58-
[]
59-
)->joinLeft(
60-
['pds' => $this->getTable('catalog_product_entity_decimal')],
61-
sprintf(
62-
'pds.%s = pdd.%s AND pds.attribute_id = pdd.attribute_id'.' AND pds.store_id=cs.store_id',
63-
$productIdField,
64-
$productIdField
65-
),
66-
[]
67-
)->joinLeft(
60+
$query = $select->insertFromSelect($idxTable);
61+
$connection->query($query);
62+
63+
return $this;
64+
}
65+
66+
/**
67+
* Generate select with attribute values
68+
*
69+
* @param array $attributeIds
70+
* @param array|null $entityIds
71+
* @param bool $storeValuesOnly
72+
* @return Select
73+
* @throws \Exception
74+
*/
75+
private function getSelect(array $attributeIds, ?array $entityIds, bool $storeValuesOnly = false): Select
76+
{
77+
$productIdField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
78+
$connection = $this->getConnection();
79+
$select = $connection->select()
80+
->from(
81+
['cs' => $this->getTable('store')],
82+
[]
83+
);
84+
if ($storeValuesOnly) {
85+
$select->join(
86+
['pdd' => $this->getTable('catalog_product_entity_decimal')],
87+
'pdd.store_id = cs.store_id',
88+
[]
89+
);
90+
$productValueExpression = 'pdd.value';
91+
} else {
92+
$select->join(
93+
['pdd' => $this->getTable('catalog_product_entity_decimal')],
94+
'pdd.store_id=' . Store::DEFAULT_STORE_ID,
95+
[]
96+
)->joinLeft(
97+
['pds' => $this->getTable('catalog_product_entity_decimal')],
98+
sprintf(
99+
'pds.%s = pdd.%s AND pds.attribute_id = pdd.attribute_id' . ' AND pds.store_id=cs.store_id',
100+
$productIdField,
101+
$productIdField
102+
),
103+
[]
104+
);
105+
$productValueExpression = $connection->getCheckSql('pds.value_id > 0', 'pds.value', 'pdd.value');
106+
}
107+
$select->joinLeft(
68108
['cpe' => $this->getTable('catalog_product_entity')],
69109
"cpe.{$productIdField} = pdd.{$productIdField}",
70110
[]
71-
)->where(
72-
'pdd.store_id=?',
73-
\Magento\Store\Model\Store::DEFAULT_STORE_ID
74111
)->where(
75112
'cs.store_id!=?',
76-
\Magento\Store\Model\Store::DEFAULT_STORE_ID
113+
Store::DEFAULT_STORE_ID
77114
)->where(
78115
'pdd.attribute_id IN(?)',
79-
$attrIds
116+
$attributeIds,
117+
Zend_Db::INT_TYPE
80118
)->where(
81119
"{$productValueExpression} IS NOT NULL"
82120
)->columns(
@@ -105,7 +143,11 @@ protected function _prepareIndex($entityIds = null, $attributeId = null)
105143
);
106144

107145
if ($entityIds !== null) {
108-
$select->where('cpe.entity_id IN(?)', $entityIds);
146+
$select->where(
147+
'cpe.entity_id IN(?)',
148+
$entityIds,
149+
Zend_Db::INT_TYPE
150+
);
109151
}
110152

111153
/**
@@ -121,10 +163,7 @@ protected function _prepareIndex($entityIds = null, $attributeId = null)
121163
]
122164
);
123165

124-
$query = $select->insertFromSelect($idxTable);
125-
$connection->query($query);
126-
127-
return $this;
166+
return $select;
128167
}
129168

130169
/**

0 commit comments

Comments
 (0)