Skip to content

Commit 0f4569b

Browse files
author
Roman Leshchenko
committed
Merge branch '2.2.6-develop' of github.com:magento/magento2ce into MAGETWO-90468
2 parents 4f70a94 + 4323706 commit 0f4569b

File tree

38 files changed

+1655
-705
lines changed

38 files changed

+1655
-705
lines changed

app/code/Magento/Catalog/Console/Command/PriceIndexerDimensionsModeSetCommand.php

Lines changed: 0 additions & 196 deletions
This file was deleted.

app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Indexer.php

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,36 @@ public function __construct(
5656
* @return \Magento\Catalog\Model\Indexer\Product\Flat
5757
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5858
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
59+
* @SuppressWarnings(PHPMD.NPathComplexity)
5960
*/
6061
public function write($storeId, $productId, $valueFieldSuffix = '')
6162
{
6263
$flatTable = $this->_productIndexerHelper->getFlatTableName($storeId);
64+
$entityTableName = $this->_productIndexerHelper->getTable('catalog_product_entity');
6365

6466
$attributes = $this->_productIndexerHelper->getAttributes();
6567
$eavAttributes = $this->_productIndexerHelper->getTablesStructure($attributes);
6668
$updateData = [];
6769
$describe = $this->_connection->describeTable($flatTable);
70+
$metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
71+
$linkField = $metadata->getLinkField();
6872

6973
foreach ($eavAttributes as $tableName => $tableColumns) {
7074
$columnsChunks = array_chunk($tableColumns, self::ATTRIBUTES_CHUNK_SIZE, true);
7175

7276
foreach ($columnsChunks as $columns) {
7377
$select = $this->_connection->select();
74-
$selectValue = $this->_connection->select();
75-
$keyColumns = [
76-
'entity_id' => 'e.entity_id',
77-
'attribute_id' => 't.attribute_id',
78-
'value' => $this->_connection->getIfNullSql('`t2`.`value`', '`t`.`value`'),
79-
];
80-
81-
if ($tableName != $this->_productIndexerHelper->getTable('catalog_product_entity')) {
78+
79+
if ($tableName != $entityTableName) {
8280
$valueColumns = [];
8381
$ids = [];
8482
$select->from(
85-
['e' => $this->_productIndexerHelper->getTable('catalog_product_entity')],
86-
$keyColumns
87-
);
88-
89-
$selectValue->from(
90-
['e' => $this->_productIndexerHelper->getTable('catalog_product_entity')],
91-
$keyColumns
83+
['e' => $entityTableName],
84+
[
85+
'entity_id' => 'e.entity_id',
86+
'attribute_id' => 't.attribute_id',
87+
'value' => $this->_connection->getIfNullSql('`t2`.`value`', '`t`.`value`'),
88+
]
9289
);
9390

9491
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
@@ -97,8 +94,7 @@ public function write($storeId, $productId, $valueFieldSuffix = '')
9794
$ids[$attribute->getId()] = $columnName;
9895
}
9996
}
100-
$linkField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
101-
$select->joinLeft(
97+
$select->joinInner(
10298
['t' => $tableName],
10399
sprintf('e.%s = t.%s ', $linkField, $linkField) . $this->_connection->quoteInto(
104100
' AND t.attribute_id IN (?)',
@@ -116,8 +112,6 @@ public function write($storeId, $productId, $valueFieldSuffix = '')
116112
[]
117113
)->where(
118114
'e.entity_id = ' . $productId
119-
)->where(
120-
't.attribute_id IS NOT NULL'
121115
);
122116
$cursor = $this->_connection->query($select);
123117
while ($row = $cursor->fetch(\Zend_Db::FETCH_ASSOC)) {
@@ -157,7 +151,7 @@ public function write($storeId, $productId, $valueFieldSuffix = '')
157151
$columnNames[] = 'attribute_set_id';
158152
$columnNames[] = 'type_id';
159153
$select->from(
160-
['e' => $this->_productIndexerHelper->getTable('catalog_product_entity')],
154+
['e' => $entityTableName],
161155
$columnNames
162156
)->where(
163157
'e.entity_id = ' . $productId
@@ -175,7 +169,9 @@ public function write($storeId, $productId, $valueFieldSuffix = '')
175169

176170
if (!empty($updateData)) {
177171
$updateData += ['entity_id' => $productId];
178-
$updateData += ['row_id' => $productId];
172+
if ($linkField !== $metadata->getIdentifierField()) {
173+
$updateData += [$linkField => $productId];
174+
}
179175
$updateFields = [];
180176
foreach ($updateData as $key => $value) {
181177
$updateFields[$key] = $key;

0 commit comments

Comments
 (0)