Skip to content

Commit b8cd42f

Browse files
author
Olexandr Lysenko
committed
Merge branch 'MAGETWO-60397' into bugfixes
2 parents 1dc6c4e + ff20a0d commit b8cd42f

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
281281
if (!empty($columnValueNames)) {
282282
$select->joinLeft(
283283
$temporaryValueTableName,
284-
sprintf('e.%1$s = %2$s.%1$s', $linkField, $temporaryTableName),
284+
sprintf('e.%1$s = %2$s.%1$s', $linkField, $temporaryValueTableName),
285285
$columnValueNames
286286
);
287287
$allColumns = array_merge($allColumns, $columnValueNames);

app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/Flat/FlatTableBuilderTest.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,42 @@ protected function setUp()
107107

108108
public function testBuild()
109109
{
110-
list($storeId, $changedIds, $valueFieldSuffix, $tableDropSuffix, $fillTmpTables) = [1, [], '', '', true];
110+
$storeId = 1;
111+
$changedIds = [];
112+
$valueFieldSuffix = '_value';
113+
$tableDropSuffix = '';
114+
$fillTmpTables = true;
111115
$tableName = 'catalog_product_entity';
112116
$attributeTable = 'catalog_product_entity_int';
113117
$temporaryTableName = 'catalog_product_entity_int_tmp_indexer';
114-
$temporaryValueTableName = 'catalog_product_entity_int_tmp_indexer';
118+
$temporaryValueTableName = 'catalog_product_entity_int_tmp_indexer_value';
115119
$linkField = 'entity_id';
116120
$statusId = 22;
121+
$eavCustomField = 'space_weight';
122+
$eavCustomValueField = $eavCustomField . $valueFieldSuffix;
117123
$this->flatIndexerMock->expects($this->once())->method('getAttributes')->willReturn([]);
118124
$this->flatIndexerMock->expects($this->exactly(3))->method('getFlatColumns')
119125
->willReturnOnConsecutiveCalls(
120126
[],
121-
[$linkField => []],
122-
[$linkField => []]
127+
[$eavCustomValueField => []],
128+
[$eavCustomValueField => []]
123129
);
124130
$this->flatIndexerMock->expects($this->once())->method('getFlatIndexes')->willReturn([]);
125131
$statusAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
126132
->disableOriginalConstructor()
127133
->getMock();
134+
$eavCustomAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class)
135+
->disableOriginalConstructor()
136+
->getMock();
128137
$this->flatIndexerMock->expects($this->once())->method('getTablesStructure')
129138
->willReturn(
130139
[
131140
'catalog_product_entity' => [
132141
$linkField => $statusAttributeMock
133142
],
134143
'catalog_product_entity_int' => [
135-
$linkField => $statusAttributeMock
144+
$linkField => $statusAttributeMock,
145+
$eavCustomField => $eavCustomAttributeMock
136146
]
137147
]
138148
);
@@ -155,6 +165,9 @@ public function testBuild()
155165
$statusAttributeMock->expects($this->atLeastOnce())->method('getBackend')->willReturn(
156166
$backendMock
157167
);
168+
$eavCustomAttributeMock->expects($this->atLeastOnce())->method('getBackend')->willReturn(
169+
$backendMock
170+
);
158171
$statusAttributeMock->expects($this->atLeastOnce())->method('getId')->willReturn($statusId);
159172
$tableMock = $this->getMockBuilder(\Magento\Framework\DB\Ddl\Table::class)
160173
->disableOriginalConstructor()
@@ -185,12 +198,12 @@ public function testBuild()
185198
[
186199
$temporaryTableName,
187200
"e.{$linkField} = {$temporaryTableName}.{$linkField}",
188-
[$linkField]
201+
[$linkField, $eavCustomField]
189202
],
190203
[
191204
$temporaryValueTableName,
192-
"e.{$linkField} = " . $temporaryValueTableName . ".{$linkField}",
193-
[$linkField]
205+
"e.{$linkField} = {$temporaryValueTableName}.{$linkField}",
206+
[$eavCustomValueField]
194207
]
195208
)->willReturnSelf();
196209
$this->metadataPoolMock->expects($this->atLeastOnce())->method('getMetadata')->with(ProductInterface::class)

0 commit comments

Comments
 (0)