perarg Posted April 3, 2018 Share Posted April 3, 2018 (edited) Hello, i am creating a module which already add a column in an existing db table. More specific, in `stock_available` table i add a column let's call it quantity2. So far so good. My need, among others, is to edit controllers/admin/AdminProductsController.php at about line 185-187 and make some little changes at $this->_select variable. So just for testing purposes i changed that and everything works as i expected. My problem is that i don't want to edit that file directly neither make some kind of override. I want a more safe solution only through the module. That is to say, when the module is installed the changes are applied. When the module is uninstalled everything goes back to normal. How is the more appropriate way to achieve that ? Edited April 3, 2018 by perarg (see edit history) Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted April 4, 2018 Share Posted April 4, 2018 Hi... you can override controller in your module folder.like "your_modulefolder/override/controllers/admin/AdminProductsController.php" Read this http://doc.prestashop.com/display/PS16/Creating+a+first+module Thanks Link to comment Share on other sites More sharing options...
perarg Posted April 4, 2018 Author Share Posted April 4, 2018 Thank you for reply but as i write in my first post, i don't want to override anything. It is not good practice. Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted April 5, 2018 Share Posted April 5, 2018 Hi... i say the override is your custom module folder not in prestashop directory override folder. when you install the module the override use in your module folder and when you uninstall module then everything working is normal. if (Module::isInstalled(modulenamelowercase)) { //your code here } Thanks Link to comment Share on other sites More sharing options...
perarg Posted April 6, 2018 Author Share Posted April 6, 2018 Please read the warning at this page http://doc.prestashop.com/display/PS16/Overriding+default+behaviors It is clearly says "Overrides in PrestaShop are exclusive. This means that if your module overrides one of PrestaShop's behaviors, another module will not be able to use that behavior properly, or override it in an predictable way." That is why i asked here about a way that doesn't include overriding. I would like to create a more permanent solution and i don't want to worry for malfunction of future modules... Link to comment Share on other sites More sharing options...
Jihene Heni Posted April 6, 2018 Share Posted April 6, 2018 I face the same problem i'd like to change the sql request in AdminListProduct using my module can you help me ? Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted April 7, 2018 Share Posted April 7, 2018 19 hours ago, perarg said: Please read the warning at this page http://doc.prestashop.com/display/PS16/Overriding+default+behaviors It is clearly says "Overrides in PrestaShop are exclusive. This means that if your module overrides one of PrestaShop's behaviors, another module will not be able to use that behavior properly, or override it in an predictable way." That is why i asked here about a way that doesn't include overriding. I would like to create a more permanent solution and i don't want to worry for malfunction of future modules... Yes but this is only solution with prestashop core file override.other wise you can create your module admin controller with your custom module Thanks Link to comment Share on other sites More sharing options...
perarg Posted April 7, 2018 Author Share Posted April 7, 2018 2 hours ago, Nishith said: other wise you can create your module admin controller with your custom module Sorry but i don't understand what are you trying to say. Do you have an example on this ? Or is there a module that you know it work with the same functionality so to be inspired ? 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