Nick KT Posted June 6, 2024 Share Posted June 6, 2024 I am trying to decorate the PS 8.1.6 ProductController and I am getting below error: You have requested a non-existent service "PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController". This is my service.yml file Could you please advise what I might be missing? I'm happy to provide any additional information or data that might be helpful. Link to comment Share on other sites More sharing options...
Andrei H Posted June 8, 2024 Share Posted June 8, 2024 Hello, I tried with your example and it displays the same exception for me. By looking into the documentation, it looks like this should out of the box, but it doesn't. They highlight the PrestaShopBundle\Controller\Admin\Improve\Design\CmsPageController in there, which works as expected if you try to decorate it. The main difference between these classes seems to be the fact that the Product one has a constructor. This is one way you can achieve what you want: 1. In your services.yml, define the product service as well as follows: PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController: autowire: true 2. Now you should be able to decorate the PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController service. In your decorator please add autowire: true as well, in order to avoid another exception. 3. As stated in the documentation, you will need to run bin/console cache:clear in order for your decorator to override the routes exposed by the default controller. Let me know if the above helps. 1 Link to comment Share on other sites More sharing options...
Nick KT Posted June 8, 2024 Author Share Posted June 8, 2024 1 hour ago, Andrei H said: Hello, I tried with your example and it displays the same exception for me. By looking into the documentation, it looks like this should out of the box, but it doesn't. They highlight the PrestaShopBundle\Controller\Admin\Improve\Design\CmsPageController in there, which works as expected if you try to decorate it. The main difference between these classes seems to be the fact that the Product one has a constructor. This is one way you can achieve what you want: 1. In your services.yml, define the product service as well as follows: PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController: autowire: true 2. Now you should be able to decorate the PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController service. In your decorator please add autowire: true as well, in order to avoid another exception. 3. As stated in the documentation, you will need to run bin/console cache:clear in order for your decorator to override the routes exposed by the default controller. Let me know if the above helps. Many many tanks, it worked. 1 Link to comment Share on other sites More sharing options...
Nick KT Posted June 9, 2024 Author Share Posted June 9, 2024 Need help again I don't know why I am facing so much difficulties to decorating the new PS8.X productController and there documentation doesn't help at all. Now I am getting this error: Quote The controller for URI "/sell/catalog/products-v2/" is not callable: Controller "PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController" cannot be fetched from the container because it is private. Did you forget to tag the service with "controller.service_arguments"? I have tried to follow the symfony's examples by adding these tags prestashop.core.controllers, controller.service_arguments, container.service_subscriber, which I could see are in original controller but it didn't helped. services: PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController: autowire: true custom_product_controller: autowire: true class: mymodule\Controller\Admin\customProductController decorates: PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController arguments: ["@custom_product_controller.inner"] tags: ['controller.service_arguments'] Do you or anybody else knows what I have to do add/remove to make it work. Thanks in advance Link to comment Share on other sites More sharing options...
Andrei H Posted June 10, 2024 Share Posted June 10, 2024 Hello, Just taking a wild guess here. Have you tried adding public: true? 1 Link to comment Share on other sites More sharing options...
Nick KT Posted June 10, 2024 Author Share Posted June 10, 2024 ones again thanks it worked, I added as below and it worked. PrestaShopBundle\Controller\Admin\Sell\Catalog\Product\ProductController: autowire: true public: true Many thanks 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now