From 0877a67807c94130bc44247741c7557babf26e43 Mon Sep 17 00:00:00 2001 From: Oleksandr Melnyk Date: Tue, 29 Dec 2020 12:36:37 +0200 Subject: [PATCH 1/2] magento/magento2#31361: Magento 2 custom attribute filter not working graphql products query in product attribute custom source - fixed attribute values mapping for inputs of select type --- .../Model/Adapter/BatchDataMapper/ProductDataMapper.php | 8 ++++---- app/code/Magento/Test/etc/schema.graphqls | 0 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/Test/etc/schema.graphqls diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php index 0edc63b10f9ab..5931d9bc4b5a3 100644 --- a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php +++ b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php @@ -6,14 +6,14 @@ namespace Magento\Elasticsearch\Model\Adapter\BatchDataMapper; +use Magento\AdvancedSearch\Model\Adapter\DataMapper\AdditionalFieldsProviderInterface; use Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider; +use Magento\Eav\Api\Data\AttributeOptionInterface; use Magento\Eav\Model\Entity\Attribute; +use Magento\Elasticsearch\Model\Adapter\BatchDataMapperInterface; use Magento\Elasticsearch\Model\Adapter\Document\Builder; use Magento\Elasticsearch\Model\Adapter\FieldMapperInterface; -use Magento\Elasticsearch\Model\Adapter\BatchDataMapperInterface; use Magento\Elasticsearch\Model\Adapter\FieldType\Date as DateFieldType; -use Magento\AdvancedSearch\Model\Adapter\DataMapper\AdditionalFieldsProviderInterface; -use Magento\Eav\Api\Data\AttributeOptionInterface; /** * Map product index data to search engine metadata @@ -295,7 +295,7 @@ private function prepareAttributeValues( if (in_array($attribute->getFrontendInput(), $this->filterableAttributeTypes)) { $attributeValues = array_map( function (string $valueId) { - return (int)$valueId; + return is_numeric($valueId) ? (int)$valueId : $valueId; }, $attributeValues ); diff --git a/app/code/Magento/Test/etc/schema.graphqls b/app/code/Magento/Test/etc/schema.graphqls new file mode 100644 index 0000000000000..e69de29bb2d1d From 547ab1ed0a118c71d825ded6d827871c475712dd Mon Sep 17 00:00:00 2001 From: Oleksandr Melnyk Date: Tue, 29 Dec 2020 12:45:45 +0200 Subject: [PATCH 2/2] Delete schema.graphqls --- app/code/Magento/Test/etc/schema.graphqls | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/code/Magento/Test/etc/schema.graphqls diff --git a/app/code/Magento/Test/etc/schema.graphqls b/app/code/Magento/Test/etc/schema.graphqls deleted file mode 100644 index e69de29bb2d1d..0000000000000