Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    hyperlocal-marketplace-guide

    How to add filter before listing product and search suggestion in Shopware6

    Introduction

    In this topic we discuss about how to be add filter before listing product and search suggestion result in Shopware6. If you want to add filter on product listing , product search suggestion list and product search result event, then please follow this article.

    Overview

    We can achieve this solution by subscribed event for corresponding result view. like as ProductListingCriteriaEvent for listing product, ProductSuggestCriteriaEvent for product search suggestion and ProductSearchCriteriaEvent for product search result page.

    Subscribed Event in Subscriber

    First we create subscriber file ProductResultCriteriaSubscriber.php for subscribed multiple event and register it in config.xml file. After creating subscriber file , subscribed ProductListingCriteriaEvent and ProductSuggestCriteriaEvent class with relative functions in getSubscribedEvents function. After creating functions for Event class we can add filter in existing product result criteria. Getting existing criteria through event and add it own filter for desired results.
    Like here we filter some desired products ids in current criteria. So get current criteria by $event and add new filter.

    How to upload media through URL

    Register Subscriber

    After creating subscriber file need to register it config.xml file for global accessing .So we create config.xml file in config folder and register the subscriber.

    <service id=”Webkul\MPHyperlocal\Subscriber\ProductResultCriteriaSubscriber” public=”true”> <tag name=”kernel.event_subscriber” /> <argument type=”service” id=”service_container” /> </service>

    Final Summary

    Now filter listing all product according to your custom criteria on storefront.

    Thanks for reading, so i hope it will help you. Happy coding 🙂

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close