From 9c731d022d10d2c9a048a3481a42890290d3db33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Mon, 18 Dec 2017 08:51:11 +0100 Subject: [PATCH 1/2] Fix #660 : fatal error in attribute autocomplete. --- .../Product/Attribute/DataProvider.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php b/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php index 5d5b3acfe..f17cce3b7 100644 --- a/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php +++ b/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php @@ -106,12 +106,17 @@ public function getItems() $filterField = $this->attributeConfig->getFilterField($attribute); $facetData = $this->productCollection->getFacetedData($filterField); - foreach ($facetData as $currentFilter) { - if ($currentFilter['value'] != '__other_docs') { - $currentFilter['attribute_code'] = $attribute->getAttributeCode(); - $currentFilter['attribute_label'] = $attribute->getStoreLabel(); - $currentFilter['type'] = $this->getType(); - $items[] = $this->itemFactory->create($currentFilter); + foreach ($facetData as $filterValue => $currentFilter) { + if ($filterValue != '__other_docs') { + $itemData = [ + 'value' => $filterValue, + 'attribute_code' => $attribute->getAttributeCode(), + 'attribute_label' => $attribute->getStoreLabel(), + 'type' => $this->getType(), + 'count' => $currentFilter['count'] + + ]; + $items[] = $this->itemFactory->create($itemData); } } } From 761ae24bc7c858ab62d8017b3c92e9aeafd135d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Mon, 18 Dec 2017 08:56:37 +0100 Subject: [PATCH 2/2] Code cleaning. --- .../Model/Autocomplete/Product/Attribute/DataProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php b/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php index f17cce3b7..061a2d3f0 100644 --- a/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php +++ b/src/module-elasticsuite-catalog/Model/Autocomplete/Product/Attribute/DataProvider.php @@ -113,7 +113,7 @@ public function getItems() 'attribute_code' => $attribute->getAttributeCode(), 'attribute_label' => $attribute->getStoreLabel(), 'type' => $this->getType(), - 'count' => $currentFilter['count'] + 'count' => $currentFilter['count'], ]; $items[] = $this->itemFactory->create($itemData);