Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    How to add the custom listing in the storefront at the Shopware

    In this blog, you are going to learn “How to add the custom listing in the storefront at the Shopware.”
    I hope you know the directory structure of Shopware 6 plugin, if you don’t know, see here-

    New product listing filters can be registered via the event \Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent. This event will be fire when the Criteria object is creating for the listing. The event can use to respond to the request to add new filters or aggregations to the Criteria object. Afterward, it is important to register for the event \Shopware\Core\Content\Product\Events\ProductListingResultEvent to add the filtered values to the result. 

    The sorting in the product listing is controlled by the \Shopware\Core\Content\Product\SalesChannel\Listing\ProductListingSortingRegistry. All classes in this registry represent a selectable sort in the listing. The \Shopware\Core\Content\Product\SalesChannel\Listing\ProductListingSorting can easily be defined via DI-Container. By the container tag shopware.sales_channel.product_listing.sorting these are then registered in the registry.


    Entity extension

    If you’re wondering how to extend existing core entities, this ‘HowTo’ will have you covered. Do not confuse entity extensions with entities’ custom fields though, as they serve a different purpose. In short: Extensions are technical and not configurable by the admin user just like that. Also, they can deal with more complex types than scalar ones. Custom fields are, by default, configurable by the admin user in the administration and they mostly support scalar types, e.g. a text-field, a number field 

    Own entities can be integrated into the core via the corresponding entry in the services.xml. To extend existing entities, the abstract class \Shopware\Core\Framework\DataAbstractionLayer\EntityExtension is used. The EntityExtension must define which entity should extend in the method. Once this extension access in the system, the extension can add more fields to it:

    This example adds another association named custom_struct to the ProductDefinition. The Runtime flag tells the data abstraction layer, that you’re going to take care of the field’s content yourself. Have a look at our detailed list of flags and what their purpose is, or find out which field types are available in Shopware 6.

    So, time to take care of the product entities’ new field yourself. You’re going to need a new subscriber for this. Have a look here to find out how to properly add your own subscriber class.

    As you can see, the subscriber listens to the PRODUCT_LOADED event, which is triggered every time a set of products is requested. The listener onProductsLoaded then adds a custom struct into the new field.


    I hope it will help you. Thanks for reading. Happy Coding 🙂
    Thank You.

    . . .

    Comments (2)

    Add Your Comment

  • Rafaëla Bg
    Hi, would you please make a tutorial on how to show the top sellers product for a given category ?

    Good job for the tutorials.

    • Adarsh Shukla
      Hello, Thanks for your valuable comment. Glad to know that it helps you. We will create a user guide. For any other queries, please mail us at
  • Back to Top
    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