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

    Custom Storefront Controller in Shopware6

    Introduction

    This article give you a brief introduction on how to create a custom storefront controller in shopware6. If you want to create you own plugin then you need to know how to create a custom controller in storefront.

    Overview

    If you want to perform some custom business logic from your storefront , you will need to create a storefront controller . This article about to create a new product with help of custom controller.

    Controller Class

    For create a custom storefront controller in shopware6 . Create a class inside the <plugin base>/src/Storefront/Controller and name it ProductController.

    Register controller in route

    Next you have to tell Symfony that it should search for routes in your /Controller folder. Therefore add an routes.xml inside the <plugin base>/src/Resources/config folder.

    Register Controller in service

    Now you need to register your controller in the DI-Container, therefore edit the Resources/config/services.xml to look like this:

    Rendering Template

    Lastly your Controller Action needs to return a Response object. You can render an own template via $this->renderStorefront() or forward to another action.

    Triggering your controller

    Now you need to trigger your custom action somehow. Add a anchor element that has an href to your route:

    To learn about more about this topic, there is a link.

    I hope It will help you. Thanks for reading 🙂

    . . .

    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