最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

shopware6 - How to extend the search criteria in ProductSearchCriteriaEvent to include additional product - Stack Overflow

programmeradmin1浏览0评论

I want to extend the search criteria in ProductSearchCriteriaEvent to include additional products (e.g., by ID or category) while preserving the existing search behavior (e.g., matching a user’s search term). The products are reachable but are not appearing in the storefront search results when the following subscriber is enabled.

Here's the code example to include two additional products by its its product numbers, but it is not working - blank search results

class ProductSearchSubscriber implements EventSubscriberInterface
{
  public static function getSubscribedEvents(): array
  {
    return [
      ProductSearchCriteriaEvent::class => 'extendSearchCriteria',
    ];
  }
  public function extendSearchCriteria(ProductSearchCriteriaEvent $event): void
  {
    $criteria = $event->getCriteria();
    $criteria->addFilter(new OrFilter([
      new EqualsFilter('productNumber', 'SW000001'),
      new EqualsFilter('productNumber', 'SW000002'),
    ]));
  }
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论