Skip to content

Commit

Permalink
MAGETWO-87358: #12717 - Catalog Products List widget is not displayed…
Browse files Browse the repository at this point in the history
… on Storefront #12765
  • Loading branch information
ishakhsuvarov authored Feb 6, 2018
2 parents 44a0ec1 + ec24990 commit 788e0f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
10 changes: 10 additions & 0 deletions app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ public function afterSave()
return parent::afterSave();
}

/**
* Is attribute enabled for flat indexing
*
* @return bool
*/
public function isEnabledInFlat()
{
return $this->_isEnabledInFlat();
}

/**
* Is attribute enabled for flat indexing
*
Expand Down
17 changes: 15 additions & 2 deletions app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,21 @@ public function addToCollection($collection)
$attribute = $this->getAttributeObject();

if ($collection->isEnabledFlat()) {
$alias = array_keys($collection->getSelect()->getPart('from'))[0];
$this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.' . $attribute->getAttributeCode();
if ($attribute->isEnabledInFlat()) {
$alias = array_keys($collection->getSelect()->getPart('from'))[0];
$this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.' . $attribute->getAttributeCode();
} else {
$alias = 'at_' . $attribute->getAttributeCode();
if (!in_array($alias, array_keys($collection->getSelect()->getPart('from')))) {
$collection->joinAttribute(
$attribute->getAttributeCode(),
'catalog_product/'.$attribute->getAttributeCode(),
'entity_id'
);
}

$this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.value';
}
return $this;
}

Expand Down

0 comments on commit 788e0f0

Please sign in to comment.