Search code examples
symfonysymfony5shopwareshopware6

How to prority route


I have overwritten the controller in the application by overwritten route and it works, but also installed another plugin that overwritten the same route as I overwritten (this plugin cannot be changed) and now this route is supported by the shopware, not mine.

this is my controller I want to display

namespace MyPlugin\Core\Checkout\Customer\SalesChannel;

...
class ChangeCustomerProfileRoute extends AbstractChangeCustomerProfileRoute
{
     * @Route(path="/store-api/account/change-profile", name="store-api.account.change-profile", methods={"POST"})
     */
    public function change(RequestDataBag $data, SalesChannelContext $context, CustomerEntity $customer): SuccessResponse

...

this is controller in a another plugin -I don’t want to show it (I need this plugin because I need functionalities, but I don’t need this route)

namespace StorePlugin\Core\Checkout\Customer\SalesChannel;

...
class ChangeCustomerProfileRoute extends AbstractChangeCustomerProfileRoute
{
     * @Route(path="/store-api/account/change-profile", name="store-api.account.change-profile", methods={"POST"})
     */
    public function change(RequestDataBag $data, SalesChannelContext $context, CustomerEntity $customer): SuccessResponse

...

I have read this article https://symfony.com/blog/new-in-symfony-5-1-route-annotations-priority but it does not work because this do not prioritize the name, only url.

How can I prioritize my route name to be supported by shopware?


Solution

  • The priority should be dependent on the plugin loading order, which is determined by the installation date.

    Try to install the plugin in a different order. You could also manually change the installation date in the plugin table in the database.