chamath viranga Posted October 21, 2021 Share Posted October 21, 2021 PS version (1.7.5.2) Need to override (extend) ProductController with new custom controller. PrestaShopBundle\Controller\Admin\ProductController extended (custom) controller path : modules/my_module/Controller/ service.yml path : module/my_module/config/services.yml services.yml # modules/my_module/config/services.yml ProductControllerOverride: class: my_module\Controller\ProductControllerOverride decorates: PrestaShopBundle\Controller\Admin\ProductController arguments: ['@ProductControllerOverride.inner'] I tried with prestashop controller override and decorate both methods in documentation. Still no luck. Prestashop override documentation Output of decorate method InvalidArgumentException The service file "/home/user_name/projects/my_prestashop/src/PrestaShopBundle/DependencyInjection/Compiler/../../../../modules/my_module/config//services. yml" is not valid. It should contain an array. Check your YAML syntax. 1 Link to comment Share on other sites More sharing options...
squni Posted December 14, 2021 Share Posted December 14, 2021 (edited) Hi, did you figure out how to fix it? I have the same problem and cannot find any solution on the internet... Edit: I managed to get different exeption by modifying services.yml. I added "services" in line 2 : # modules/productpersonalization/config/services.yml services: CustomController: class: ProductPersonalization\Controller\Admin\CustomController decorates: PrestaShopBundle\Controller\Admin\Sell\Order\OrderController arguments: ['@CustomController.inner'] Now I'm getting this exeption: Edited December 14, 2021 by squni New information on issue (see edit history) Link to comment Share on other sites More sharing options...
Tiamat Posted January 22, 2022 Share Posted January 22, 2022 On 12/14/2021 at 6:51 PM, squni said: Hi, did you figure out how to fix it? I have the same problem and cannot find any solution on the internet... Edit: I managed to get different exeption by modifying services.yml. I added "services" in line 2 : # modules/productpersonalization/config/services.yml services: CustomController: class: ProductPersonalization\Controller\Admin\CustomController decorates: PrestaShopBundle\Controller\Admin\Sell\Order\OrderController arguments: ['@CustomController.inner'] Now I'm getting this exeption: Hi @squni I faced the same issue too, did you found any solution for this? Link to comment Share on other sites More sharing options...
squni Posted January 28, 2022 Share Posted January 28, 2022 On 1/22/2022 at 4:11 AM, Tiamat said: Hi @squni I faced the same issue too, did you found any solution for this? Hey, unforunately I didn't. Until I have more time and idea how to fix it I just made my changes in core file ;/ Link to comment Share on other sites More sharing options...
carlos.batista Posted March 21, 2022 Share Posted March 21, 2022 Hi, any solution to this problem, i build a service override and i look the same problem with " Attempted to load class "OrderOverrideController" from namespace "MyModule\Controllers". Did you forget a "use" statement for "MyModule\controllers\OrderOverrideController"? " On 12/14/2021 at 11:51 AM, squni said: Hi, did you figure out how to fix it? I have the same problem and cannot find any solution on the internet... Edit: I managed to get different exeption by modifying services.yml. I added "services" in line 2 : # modules/productpersonalization/config/services.yml services: CustomController: class: ProductPersonalization\Controller\Admin\CustomController decorates: PrestaShopBundle\Controller\Admin\Sell\Order\OrderController arguments: ['@CustomController.inner'] Now I'm getting this exeption: Link to comment Share on other sites More sharing options...
Mahdi Shad Posted May 26, 2022 Share Posted May 26, 2022 Hi 1- Make sure your namespace is correct 2- Make sure your "autoload.php" file is created. If not: Run composer dump-autoload 3- Reinstall your module so that Prestashop can detect your "autoload.php" file Enjoy the Override feature 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