Skip to content

Commit b7a86c5

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento-gl/magento2ce into L3_Arrows_PR_20220301
2 parents 31f55cb + d6756f9 commit b7a86c5

File tree

30 files changed

+1594
-170
lines changed

30 files changed

+1594
-170
lines changed

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