Skip to content

Commit 3b7285c

Browse files
AC-1214 Fixed functional tests failing
1 parent fe48fd2 commit 3b7285c

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Collection/AbstractCollection.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,36 @@ protected function _setItemAttributeValue($valueInfo)
256256
$valueInfo['attribute_id']
257257
);
258258
$attributeCode = $attribute->getAttributeCode();
259-
if ($attribute->getIsGlobal() === ScopedAttributeInterface::SCOPE_GLOBAL) {
259+
if ((int)$attribute->getIsGlobal() === ScopedAttributeInterface::SCOPE_GLOBAL) {
260+
$entityLinkField = $this->getEntity()->getLinkField();
260261
$attributeTable = $attribute->getBackend()->getTable();
261262
$linkField = $attribute->getEntity()->getLinkField();
262263

263-
$select = $this->getConnection()
264-
->select()
265-
->from(['attr_table' => $attributeTable], "attr_table.value")
266-
->where("attr_table.attribute_id = ?", $valueInfo['attribute_id'])
267-
->where("attr_table.{$linkField} = ?", $entityId)
268-
->where('attr_table.store_id = ?', $this->getDefaultStoreId(), \Zend_Db::INT_TYPE);
269-
$data = $this->getConnection()->fetchOne($select);
270-
if ($data) {
271-
$valueInfo['value'] = $data;
264+
$select = $this->getConnection()->select()
265+
->from(
266+
['e' => $this->getEntity()->getEntityTable()],
267+
['entity_id']
268+
)
269+
->join(
270+
['t_d' => $attributeTable],
271+
"e.{$entityLinkField} = t_d.{$linkField}",
272+
['t_d.value']
273+
)->where(
274+
" e.entity_id = ?",
275+
$entityId,
276+
\Zend_Db::INT_TYPE
277+
)->where(
278+
't_d.attribute_id = ?',
279+
$attribute->getAttributeId(),
280+
\Zend_Db::INT_TYPE
281+
)->where(
282+
't_d.store_id = ?',
283+
$this->getDefaultStoreId(),
284+
\Zend_Db::INT_TYPE
285+
);
286+
$data = $this->getConnection()->fetchRow($select);
287+
if ($data && is_array($data)) {
288+
$valueInfo['value'] = $data['value'];
272289
}
273290
}
274291

0 commit comments

Comments
 (0)