# Decorate SearchBundle

**URL:** <https://forum.shopware.com/t/decorate-searchbundle/92859>\
**Category:** Plugins\
**Tags:** programming\
**Created:** [9. Februar 2022 um 12:29 UTC](https://forum.shopware.com/t/decorate-searchbundle/92859 "2022-02-09T12:29:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeroen\_treshold\_nl](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jeroen\_treshold\_nl](https://forum.shopware.com/u/jeroen_treshold_nl)\
**Post date:** [9. Februar 2022 um 12:29 UTC](https://forum.shopware.com/t/decorate-searchbundle/92859/1 "2022-02-09T12:29:53Z")

</div>

Hi,

In Shopware 5, I need to extend the standard search function (from the header) in a way that products with a cetrain condition wil be excluded from the search results. I craeted a plugin and added a service xml what contains:

> ```
> <services> 
> <service class="TresSearchExtension\SearchBundleDBAL\Condition\SearchTermConditionHandler" id="tres_search_extension.search_bundle_dbal.condition.search_term_condition_handler">
> <tag name="condition_handler_dbal" />
> </service>
> </services>
> 
> ```

In my SearchTermConditionHandler I added the supportsCondition and the generateCondition  
For testing I added some log events.  
The problem is that my SearchTermConditionHandler is not called? What ever I try I don’t get any logging information. even when I make a type in my code, it’s not executed.  
No idea what I do wrong.

Any help is welcome.

> class SearchTermConditionHandler implements ConditionHandlerInterface  
> {  
> public function supportsCondition(ConditionInterface $condition)  
> {  
> error\_log(print\_r($condition, true).„\n“, 3, Shopware()-\>DocPath() . ‚/var/log/supportsCondition\_‘ . date(„Ymd“) . ‚.log‘);
> 
> ```
> return ($condition instanceof SearchTermCondition);
> 
> ```
> 
> }
> 
> public function generateCondition(  
> ConditionInterface $condition,  
> QueryBuilder $query,  
> ShopContextInterface $context  
> ) {  
> // $query-\>andWhere(‚s\_articles\_details.instock \> 0‘);
> 
> ```
> error_log(print_r($query, true)."\n", 3, Shopware()->DocPath() . '/var/log/CategoryConditionHandler_' . date("Ymd") . '.log');
> 
> ```
> 
> }  
> }

Hope someone can help me to get further with this.

---

<div class="post-metadata">

**Author:** ![sonic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/sonic/32/25728_2.png) [@sonic](https://forum.shopware.com/u/sonic)\
**Post date:** [9. Februar 2022 um 12:44 UTC](https://forum.shopware.com/t/decorate-searchbundle/92859/2 "2022-02-09T12:44:09Z")

</div>

Missing decorates="" Tag ?

> **[Service extensions](https://developers.shopware.com/developers-guide/shopware-5-core-service-extensions/#your-extension-plugin)**
>
> Service extensions

---

<div class="post-metadata">

**Author:** ![jeroen\_treshold\_nl](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jeroen\_treshold\_nl](https://forum.shopware.com/u/jeroen_treshold_nl)\
**Post date:** [12. Februar 2022 um 05:05 UTC](https://forum.shopware.com/t/decorate-searchbundle/92859/3 "2022-02-12T05:05:30Z")

</div>

Hi, I followed the instruction from the [documentation](https://developers.shopware.com/developers-guide/shopware-5-search-bundle/#full-implementation-with-condition-(with-dbal)) (Full implementation - with condition (with DBAL))  
There is in the xml no decorates tag?

---

<div class="post-metadata">

**Author:** ![jeroen\_treshold\_nl](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jeroen\_treshold\_nl](https://forum.shopware.com/u/jeroen_treshold_nl)\
**Post date:** [20. Februar 2022 um 05:56 UTC](https://forum.shopware.com/t/decorate-searchbundle/92859/4 "2022-02-20T05:56:20Z")

</div>

Already solved it myself. Was missing some files:  
SearchExtension  
RequestHandler  
Condition
