speed-providing-uncl Posted February 18, 2018 Share Posted February 18, 2018 (edited) Hi everyone, I would like to know how to override PS 1.7 symfony controllers. The old way /override/... makes no sense here. I read this announcement http://build.prestashop.com/news/module-development-changes-in-17/#overrides-and-namespaces, but I still need to modify the product form (Form), the way it's handled (Controller) and the way it's rendered (twig template). I tried the following, based on symfony standard way of override : - created src/MyBundle/MyBundle.php with : public function getParent(){ return 'PrestaShopBundle'; } - added autoload in composer.json : "autoload": { "psr-4": { "MyBundle\\": "src/MyBundle/", - registered in app/AppKernel.php : new MyBundle\MyBundle.php - created MyBundle/Form/Admin/Product/ProductInformation.php (to override the form) with a missing } to trigger an error, to see if it's used - created Resources/views/Admin/Product/form.html.twig (to override the template), empty, to see if it's used But nothing.. I'm unable to override anything, without touching core code in src/PrestaShopBundle, which I don't want to do What is the good way? For example, I'm trying to simply add new fields to the Form. I've overriden /classes/Product with my fields, so this part is OK. I would also need to change the admin catalog view to hide some products depending on Employee, and change columns labels+data Thanks !! Florian PS: I would rather not use hookDisplayAdminProductsExtra because I want to be able to change anything on the page, not just some edit on the 4th tab Edited February 18, 2018 by Florian (see edit history) 1 Link to comment Share on other sites More sharing options...
speed-providing-uncl Posted February 18, 2018 Author Share Posted February 18, 2018 (edited) it's finally ok for templates, I had to app/console cache:clear, even if I were in debug mode, see warning in https://symfony.com/doc/2.7/templating/overriding.html but {% extends '@PrestaShopBundle/Admin/Product/form.html.twig' %} doesn't work : There are no registered paths for namespace "PrestaShopBundle" in "PrestaShopBundle:Admin\Product:form.html.twig" at line 1. edit: Finally no need to extends because there's no {block} to override, so I ended up with a whole copy/paste. And for the controller, I did a hook for hookActionProductUpdate, where you can do $product = $params['product']; then modify it with $_POST and finally $product->save() Edited February 18, 2018 by Florian (see edit history) 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