title: How to make custom product attribute searchable in Shopware?
body: <p>I'm new in Shopware.
  I understood how to add custom attribute but I can't find how to make it searchable. I got stuck.
  It's necessary to add ISBN field to product and make it as searchable as Item number.
  I saw <a href="https://developers.shopware.com/developers-guide/elasticsearch/#extend-product-search-query" rel="nofollow noreferrer">this</a> and downloaded "ZIP package of this plugin" there, but everything I got from this is fatal error on search result page:</p>
  
  <pre>
  Facet ShopwarePlugins\SwagESProduct\SearchBundle\SalesFacet not supported in engine/Shopware/Bundle/SearchBundleDBAL/ProductNumberSearch.php on line 196
  
  Stack trace:
  
  #0 engine/Shopware/Bundle/SearchBundleDBAL/ProductNumberSearch.php(149): Shopware\Bundle\SearchBundleDBAL\ProductNumberSearch->getFacetHandler(Object(ShopwarePlugins\SwagESProduct\SearchBundle\SalesFacet))
  #1 engine/Shopware/Bundle/SearchBundleDBAL/ProductNumberSearch.php(96): Shopware\Bundle\SearchBundleDBAL\ProductNumberSearch->createFacets(Object(Shopware\Bundle\SearchBundle\Criteria), Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
  #2 engine/Shopware/Bundle/SearchBundle/ProductSearch.php(65): Shopware\Bundle\SearchBundleDBAL\ProductNumberSearch->search(Object(Shopware\Bundle\SearchBundle\Criteria), Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
  #3 engine/Shopware/Controllers/Frontend/Search.php(76): Shopware\Bundle\SearchBundle\ProductSearch->search(Object(Shopware\Bundle\SearchBundle\Criteria), Object(Shopware\Bundle\StoreFrontBundle\Struct\ShopContext))
  #4 engine/Library/Enlight/Controller/Action.php(159): Shopware_Controllers_Frontend_Search->defaultSearchAction()
  #5 engine/Library/Enlight/Controller/Dispatcher/Default.php(523): Enlight_Controller_Action->dispatch('defaultSearchAc...')
  #6 engine/Library/Enlight/Controller/Front.php(223): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
  #7 engine/Shopware/Kernel.php(180): Enlight_Controller_Front->dispatch()
  #8 vendor/symfony/http-kernel/HttpCache/HttpCache.php(491): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
  #9 engine/Shopware/Components/HttpCache/AppCache.php(255): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
  #10 vendor/symfony/http-kernel/HttpCache/HttpCache.php(448): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
  #11 vendor/symfony/http-kernel/HttpCache/HttpCache.php(344): Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch(Object(Symfony\Component\HttpFoundation\Request), true)
  #12 engine/Shopware/Components/HttpCache/AppCache.php(178): Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup(Object(Symfony\Component\HttpFoundation\Request), true)
  #13 vendor/symfony/http-kernel/HttpCache/HttpCache.php(210): Shopware\Components\HttpCache\AppCache->lookup(Object(Symfony\Component\HttpFoundation\Request), true)
  #14 engine/Shopware/Components/HttpCache/AppCache.php(114): Symfony\Component\HttpKernel\HttpCache\HttpCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
  #15 shopware.php(117): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
  #16 {main}
  </pre>
  
  <p>Could everybody explain me please how to make product attribute searchable in Shopware and give normal working example?
  Shopware version is 5.2.21 just in case.</p>
  
  <p>Here's what I did: <br>
  engine/Shopware/Plugins/Community/Frontend/IsbnSearch/Bootstrap.php:</p>
  
  <pre>
  
      use ShopwarePlugins\IsbnSearch\SearchTermQueryBuilder\SearchTermQueryBuilder;
      /**
       * Class Shopware_Plugins_Frontend_IsbnSearch_Bootstrap
       */
      class Shopware_Plugins_Frontend_IsbnSearch_Bootstrap extends Shopware_Components_Plugin_Bootstrap
      {
          public function install()
          {
              $this->subscribeEvent(
                  'Enlight_Bootstrap_AfterInitResource_shopware_search_es.search_term_query_builder',
                  'decorateSearchTermQueryBuilder'
              );
  
              return true;
          }
  
          public function decorateSearchTermQueryBuilder()
          {
              $searchTermQueryBuilder = new SearchTermQueryBuilder(
                  $this->get('shopware_search_es.search_term_query_builder')
              );
              Shopware()->Container()->set('shopware_search_es.search_term_query_builder', $searchTermQueryBuilder);
          }
      }
  
  </pre>
  
  <p>engine/Shopware/Plugins/Community/Frontend/IsbnSearch/SearchTermQueryBuilder/SearchTermQueryBuilder.php:</p>
  
  <pre>
  
      namespace ShopwarePlugins\IsbnSearch\SearchTermQueryBuilder;
  
      use ONGR\ElasticsearchDSL\Query\BoolQuery;
      use ONGR\ElasticsearchDSL\Query\MultiMatchQuery;
      use Shopware\Bundle\SearchBundleES\SearchTermQueryBuilderInterface;
      use Shopware\Bundle\StoreFrontBundle\Struct\ShopContextInterface;
  
      class SearchTermQueryBuilder implements SearchTermQueryBuilderInterface
      {
          /**
           * @var SearchTermQueryBuilderInterface
           */
          private $decoratedQueryBuilder;
  
          /**
           * @param SearchTermQueryBuilderInterface $decoratedQueryBuilder
           */
          public function __construct(SearchTermQueryBuilderInterface $decoratedQueryBuilder)
          {
              $this->decoratedQueryBuilder = $decoratedQueryBuilder;
          }
  
          /**
           * @param ShopContextInterface $context
           * @param $term
           * @return BoolQuery
           */
          public function buildQuery(ShopContextInterface $context, $term)
          {
              $query = $this->decoratedQueryBuilder->buildQuery($context, $term);
  
              $matchQuery = new MultiMatchQuery(
                  ['attributes.properties.swag_es_product.isbn'],
                  $term
              );
              $query->add($matchQuery, BoolQuery::SHOULD);
  
              return $query;
          }
      }
  
  </pre>
  
  <p>I removed the rest of a code. Cause it just threw the error above. But looks like it's not enough.
  Here's how attribute was created:</p>
  
  <pre>
  
      $service = $this->container->get('shopware_attribute.crud_service');
      $service->update('s_articles_attributes', 'isbn', 'string');
  
      $service->update('s_articles_attributes', 'isbn', 'string', [
                  'label' => 'ISBN',
                  'supportText' => 'ISBN',
                  'helpText' => 'ISBN',
                  'translatable' => true,
                  'displayInBackend' => true,
                  'entity' => 'Shopware\Models\Article\Article',
                  'position' => 140,
                  'custom' => true,
                  'unique' => true,
              ]); 
  
  </pre>