Jump to content

PS 1.7.8.8 : remap, override or decorate ?


Recommended Posts

I'm trying to add some information in admin order's page on each product. So far I've been able to find where I can inject the values I want to use: It's in PrestaShopBundle\Controller\Admin\Sell\Order\OrderController.php

Now I want to change the behaviour of public function viewAction
on return $this->render('@PrestaShop/Admin/Sell/Order/Order/view.html.twig',

I want to add an array of values to use in my order view (twig) and if I change the core file, it works.

I've readed https://devdocs.prestashop-project.org/8/modules/concepts/controllers/admin-controllers/override-decorate-controller/ and I've 3 solutions:
I copied OrderController.php in my module and I created routes.yml as this:

admin_orders_view:
    path: /{orderId}/view
    methods: [GET,POST]
    defaults:
      _controller: 'mymodule\controllers\admin\sell\order\OrderController::viewAction'
      _disable_module_prefix: true

Path is correct (copy/paste from file explorer) but I get "The controller for URI "/1/view" is not callable: Class "mymodule\controllers\admin\sell\order\OrderController" does not exist." I tried all possible syntax without success (lower/uppercase, with/whitout Controller....) no way to get it to work.

So I tried to do it by overriding or decorating the controller. Since I only want to add a value to the rendering, do I have to override the whole controller, the whole viewAction function or can I do it somehow else ? but no way to call the decorator....it's like it doesn't exists.

I figure out I'm quite bad in OOP programming and in Symfony, and I lack the knowledge in this field but unfortunately I'm in a hurry and will learn while doing things, but since I'm alone to work on this module and can't ask somebody else, I need your help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...