Shopware 6 plugin: How to configure quick search options

28 Views Asked by At

I'm developing a Shopware 6 plugin where I need to make the search quick search component configurable, allowing the user to set options like:

  • Whether to show country select
  • Default search country
  • Show detailed link in pins

In my plugin I have a configuration with elements like:

<config>
  <elements>
    <select>
      <name>showCountrySelect</name>
      <options>
        <option value="true">Yes</option>
        <option value="false">No</option>
      </options>
    </select>

    <select>
      <name>defaultSearchCountry</name>
      <options>
        <option value="de">Germany</option>
        <option value="us">United States</option>
        <!-- other country options -->
      </options>
    </select>

    <select>
      <name>showDetailedLink</name>
      <options>
        <option value="true">Yes</option>
        <option value="false">No</option>
      </options>
    </select>
  </elements>
</config>

And in my subscriber I'm reading those configuration values:

// read config values
$showCountrySelect = $config->get('showCountrySelect');

Now in my plugin I want to conditionally show/hide parts of the default storefront quick search component template based on those config values.

{% sw_extends '@Storefront/storefront/component/listing/filter/filter-panel.html.twig' %}

{% block component_quick_search_form %}
  {{ parent() }}

  {% if showCountrySelect %}
 {{ countrySelect }}
  {% endif %}
  
{% endblock %}

But this does not seem to override the block properly.

0

There are 0 best solutions below