Jump to content

How to override presta Shop bundle product controller


chamath viranga

Recommended Posts

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.

 

Link to comment
Share on other sites

  • 1 month later...

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:

 

obraz.thumb.png.dfe222e564a939d13ff17f5ffa7d639a.png

Edited by squni
New information on issue (see edit history)
Link to comment
Share on other sites

  • 1 month later...
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:

 

obraz.thumb.png.dfe222e564a939d13ff17f5ffa7d639a.png

Hi @squni I faced the same issue too, did you found any solution for this?

Link to comment
Share on other sites

  • 1 month later...

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:

 

obraz.thumb.png.dfe222e564a939d13ff17f5ffa7d639a.png

 

Link to comment
Share on other sites

  • 2 months later...

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

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...