Jump to content

[8.1] Need help / documentation to decorate core ProductController with his constructor


Recommended Posts

Hello everyone,

I am currently working with Prestashop 8.1.4. I've read the documentation on how to decorate a core controller https://devdocs.prestashop-project.org/8/modules/concepts/controllers/admin-controllers/override-decorate-controller/#decorate-the-controller but the controller I try to decorate (ProductController) do not match the example (and I can't make it work).

I take another exemple with decoration of PrestaShopBundle\Controller\Admin\Sell\Catalog\SupplierController which works fine.

But PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController got a construct function which I can't find how to deal with in my decorating controller which need his own constructor.

    /**
     * @param ProductRepository $productRepository
     */
    public function __construct(ProductRepository $productRepository)
    {
        $this->productRepository = $productRepository;
    }

Here is the error raised when trying to access the website or launching any console command :

You have requested a non-existent service "PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController".

MyModule/config/services.yml :

services:
  Company\MyModule\Controller\Admin\DecoProductController:
    autowire: true
    decorates: PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController
  Company\MyModule\Controller\Admin\DecoSupplierController:
    autowire: true
    decorates: PrestaShopBundle\Controller\Admin\Sell\Catalog\SupplierController

Let me know if you need more details, if I have to attach the files I am working on ?

Tanks a lot. Best regards.

Edited by GwenaelleH (see edit history)
Link to comment
Share on other sites

  • 2 months later...
Posted (edited)

Hi there,

I was wondering if you found a solution to your question.
I'm facing the same issue on Prestashop 8.1.6 – I'm trying to decorate the ProductController but I'm encountering an error:

You have requested a non-existent service "PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController". 

The Product controller is implemented as a service.
image.thumb.png.6da238f4eff4b1b3d5f568d93cd2a84c.png

 

Edited by Nick KT (see edit history)
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...