diff --git a/Model/Config.php b/Model/Config.php index f046534d..93e170e8 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -390,9 +390,16 @@ public function getFilterWhitelist(Store $store = null) * @param Store|null $store * @return array */ - public function getFilterValuesWhitelist(Store $store = null) + public function getFilterValuesWhitelist(Store $store = null): array { $filterList = $this->getStoreConfig('tweakwise/seo/filter_values_whitelist', $store); + + if (empty($filterList)) { + return []; + } + + $filterList = trim($filterList); + $filterListExploded = explode(',', $filterList) ?: []; if (empty($filterListExploded)) { return []; @@ -400,7 +407,7 @@ public function getFilterValuesWhitelist(Store $store = null) $return = []; foreach ($filterListExploded as $listItem) { - $item = explode('=', $listItem) ?: null; + $item = explode('=', trim($listItem)) ?: null; if ($item === null) { continue; } diff --git a/Model/Seo/FilterHelper.php b/Model/Seo/FilterHelper.php index 42e07253..c1d2a678 100644 --- a/Model/Seo/FilterHelper.php +++ b/Model/Seo/FilterHelper.php @@ -118,7 +118,7 @@ protected function getAttributeCodeFromFilterItem(Item $item) * @param Item $item * @return string|null */ - protected function getAttributeValueFromFilterItem(Item $item) + protected function getAttributeValueFromFilterItem(Item $item): ?string { return $item->getAttribute()->getTitle(); } @@ -174,13 +174,11 @@ protected function isFilterValueItemInWhiteList(Item $item): bool return false; } - $isIn = \in_array( + return \in_array( strtolower($attributeValue), array_map('strtolower', $filterValuesWhiteList[$attributeCode]), true ); - - return $isIn; } /**