From d30696e873380058e5334bda2635e313d42c7371 Mon Sep 17 00:00:00 2001 From: Rostyslav Sabishchenko Date: Fri, 15 Dec 2017 16:48:19 +0200 Subject: [PATCH 1/2] #12717 - Catalog Products List widget is not displayed on Storefront --- .../Catalog/Model/ResourceModel/Eav/Attribute.php | 11 +++++++++++ .../CatalogWidget/Model/Rule/Condition/Product.php | 13 +++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php index 90b206e5a6091..f713fc79231ec 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php @@ -230,6 +230,17 @@ 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 * diff --git a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php index 9c679b8bfe9b0..9805de0bb8d34 100644 --- a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php +++ b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php @@ -119,8 +119,17 @@ 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; } From 55a3dedb56664d5f7af22446e46aba810ce662f7 Mon Sep 17 00:00:00 2001 From: Rostyslav Sabishchenko Date: Tue, 19 Dec 2017 00:55:53 +0200 Subject: [PATCH 2/2] #12717 - Catalog Products List widget is not displayed on Storefront (code styling) --- .../Magento/Catalog/Model/ResourceModel/Eav/Attribute.php | 1 - .../Magento/CatalogWidget/Model/Rule/Condition/Product.php | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php index f713fc79231ec..b29dba4c75665 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php @@ -240,7 +240,6 @@ public function isEnabledInFlat() return $this->_isEnabledInFlat(); } - /** * Is attribute enabled for flat indexing * diff --git a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php index 9805de0bb8d34..f22879df0ae0c 100644 --- a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php +++ b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php @@ -125,7 +125,11 @@ public function addToCollection($collection) } 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'); + $collection->joinAttribute( + $attribute->getAttributeCode(), + 'catalog_product/'.$attribute->getAttributeCode(), + 'entity_id' + ); } $this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.value';