{"action":"created","issue":{"url":"https://api.github.com/repos/Smile-SA/elasticsuite/issues/363","repository_url":"https://api.github.com/repos/Smile-SA/elasticsuite","labels_url":"https://api.github.com/repos/Smile-SA/elasticsuite/issues/363/labels{/name}","comments_url":"https://api.github.com/repos/Smile-SA/elasticsuite/issues/363/comments","events_url":"https://api.github.com/repos/Smile-SA/elasticsuite/issues/363/events","html_url":"https://github.com/Smile-SA/elasticsuite/issues/363","id":216023103,"number":363,"title":"Add custom filterable attribute","user":{"login":"madonzy","id":5281020,"avatar_url":"https://avatars2.githubusercontent.com/u/5281020?v=3","gravatar_id":"","url":"https://api.github.com/users/madonzy","html_url":"https://github.com/madonzy","followers_url":"https://api.github.com/users/madonzy/followers","following_url":"https://api.github.com/users/madonzy/following{/other_user}","gists_url":"https://api.github.com/users/madonzy/gists{/gist_id}","starred_url":"https://api.github.com/users/madonzy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madonzy/subscriptions","organizations_url":"https://api.github.com/users/madonzy/orgs","repos_url":"https://api.github.com/users/madonzy/repos","events_url":"https://api.github.com/users/madonzy/events{/privacy}","received_events_url":"https://api.github.com/users/madonzy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-03-22T10:57:35Z","updated_at":"2017-03-23T15:47:07Z","closed_at":"2017-03-23T15:47:07Z","body":"Is it possible to add custom filterable attribute?\r\n\r\n### Preconditions\r\n**OS**: Linux debian-8 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux\r\n**Magento Version**: 2.1.4 CE\r\n**ElasticSuite Version**: 2.3.3\r\n**Environment**: developer\r\n\r\n### Steps to reproduce\r\n1. In own module setup I use this configuration while adding the attribute:\r\n```php\r\n[\r\n                'type'                    => 'text',\r\n                'backend'                 => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\ArrayBackend',\r\n                'frontend'                => '',\r\n                'label'                   => 'Brand',\r\n                'input'                   => 'multiselect',\r\n                'class'                   => '',\r\n                'source'                  => 'XXX\\YYY\\Model\\Source\\Array',\r\n                'global'                  => ScopedAttributeInterface::SCOPE_GLOBAL,\r\n                'visible'                 => true,\r\n                'required'                => false,\r\n                'user_defined'            => true,\r\n                'default'                 => '',\r\n                'searchable'              => true,\r\n                'filterable'              => true,\r\n                'comparable'              => false,\r\n                'visible_on_front'        => true,\r\n                'used_in_product_listing' => true,\r\n                'unique'                  => false,\r\n                'apply_to'                => '',\r\n            ]\r\n```\r\n2. Add this attribute to default set\r\n3. I source model I override this method:\r\n\r\n```php\r\n/**\r\n     * {@inheritdoc}\r\n     */\r\n    public function getAllOptions()\r\n    {\r\n        if ($this->_options === null) {\r\n            $this->_options = [\r\n                [\r\n                    'value' => 'nike',\r\n                    'label' => 'Nike'\r\n                ],\r\n                [\r\n                    'value' => 'adidas',\r\n                    'label' => 'Adidas'\r\n                ],\r\n                [\r\n                    'value' => 'puma',\r\n                    'label' => 'Puma'\r\n                ]\r\n            ];\r\n\r\n            // TODO: implement brand fetching\r\n        }\r\n\r\n        return $this->_options;\r\n    }\r\n```\r\n4. Set one product to value **Adidas**, go to the category page...\r\n5. Check the front\r\n\r\n### Expected result\r\n1. My attribute will apply as filter in category page (the same as activity, style, features, etc. attributes)\r\n\r\n### Actual result\r\n1. There's no filter added :D\r\n"},"comment":{"url":"https://api.github.com/repos/Smile-SA/elasticsuite/issues/comments/288762660","html_url":"https://github.com/Smile-SA/elasticsuite/issues/363#issuecomment-288762660","issue_url":"https://api.github.com/repos/Smile-SA/elasticsuite/issues/363","id":288762660,"user":{"login":"romainruaud","id":15340849,"avatar_url":"https://avatars1.githubusercontent.com/u/15340849?v=3","gravatar_id":"","url":"https://api.github.com/users/romainruaud","html_url":"https://github.com/romainruaud","followers_url":"https://api.github.com/users/romainruaud/followers","following_url":"https://api.github.com/users/romainruaud/following{/other_user}","gists_url":"https://api.github.com/users/romainruaud/gists{/gist_id}","starred_url":"https://api.github.com/users/romainruaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romainruaud/subscriptions","organizations_url":"https://api.github.com/users/romainruaud/orgs","repos_url":"https://api.github.com/users/romainruaud/repos","events_url":"https://api.github.com/users/romainruaud/events{/privacy}","received_events_url":"https://api.github.com/users/romainruaud/received_events","type":"User","site_admin":false},"created_at":"2017-03-23T15:47:07Z","updated_at":"2017-03-23T15:47:07Z","body":"Ok I found it.\r\n\r\nYou did not properly create your attribute.\r\n\r\nFor a multiselect one, you have to use \"varchar\" as the type.\r\n\r\nIf you set it to \"text\" as you did previously, Magento will autoritary change it to \"varchar\" when you save it from the backoffice, resulting as loading empty data for product when indexing to the search engine.\r\n\r\nPlease drop your attribute, recreate it properly (as a varchar) and set your product values again, then process a full reindex.\r\n\r\nFeel free to reopen the issue if you are still encountering problem."}}
{"actor":{"display_login":"romainruaud"}}