From bd815b0e28615c7fd7b137b798b6e7c2d63622dc Mon Sep 17 00:00:00 2001 From: vo1 Date: Wed, 31 Aug 2016 10:46:53 +0200 Subject: [PATCH 1/3] Conf product may have conf. attribute not used in layered nav When configurable attribute is not used in LayeredNav, L155 fails indexation due to attribute is not in array. E.g. you have clothing with color and size, where color is always some complex naming "crimson/blood red/peach" and color_group for this is "red". Color is not used in layered while color_group is. Such solution results in Notice: Undefined offset: which is fixable by isset proposed here. --- .../Product/Indexer/Fulltext/Datasource/AttributeData.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php b/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php index 269180b91..37d5c1c04 100644 --- a/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php +++ b/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php @@ -152,7 +152,11 @@ private function addRelationData(&$parentData, $childAttributes, $relation) $configurableAttributesCodes = array_map( function ($attributeId) { - return $this->attributesById[(int) $attributeId]->getAttributeCode(); + return ( + isset($this->attributesById[(int) $attributeId]) ? + $this->attributesById[(int) $attributeId]->getAttributeCode() : + false + ); }, $relation['configurable_attributes'] ); From 9797bf511c3732dcc4d4b3f38bddc34d7988b2aa Mon Sep 17 00:00:00 2001 From: vo1 Date: Wed, 31 Aug 2016 11:11:41 +0200 Subject: [PATCH 2/3] Conf product may have conf. attribute not used in layered nav coding standards :/ --- .../Product/Indexer/Fulltext/Datasource/AttributeData.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php b/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php index 37d5c1c04..491cc0d76 100644 --- a/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php +++ b/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php @@ -153,8 +153,8 @@ private function addRelationData(&$parentData, $childAttributes, $relation) $configurableAttributesCodes = array_map( function ($attributeId) { return ( - isset($this->attributesById[(int) $attributeId]) ? - $this->attributesById[(int) $attributeId]->getAttributeCode() : + isset($this->attributesById[(int) $attributeId]) ? + $this->attributesById[(int) $attributeId]->getAttributeCode() : false ); }, From 08fee1fabba57cd3e7ec5658886225d6b5931c6b Mon Sep 17 00:00:00 2001 From: vo1 Date: Wed, 31 Aug 2016 11:25:42 +0200 Subject: [PATCH 3/3] Conf product may have conf. attribute not used in layered nav/CS Coding standards --- .../Product/Indexer/Fulltext/Datasource/AttributeData.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php b/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php index 491cc0d76..028714e4f 100644 --- a/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php +++ b/src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/AttributeData.php @@ -152,11 +152,9 @@ private function addRelationData(&$parentData, $childAttributes, $relation) $configurableAttributesCodes = array_map( function ($attributeId) { - return ( - isset($this->attributesById[(int) $attributeId]) ? - $this->attributesById[(int) $attributeId]->getAttributeCode() : - false - ); + if (isset($this->attributesById[(int) $attributeId])) { + return $this->attributesById[(int) $attributeId]->getAttributeCode(); + } }, $relation['configurable_attributes'] );