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

 - Merge Pull Request #12765 from RostislavS/magento2:issue12717
 - Merged commits:
   1. d30696e
   2. 55a3ded
  • Loading branch information
dmanners committed Feb 1, 2018
2 parents 3881f04 + 55a3ded commit ec24990
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 ec24990

Please sign in to comment.