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.