mdomski Posted January 28, 2016 Share Posted January 28, 2016 (edited) Hello I need to find best solution for following problem: I want to add custom fields to existing table in database instead of creating custom table. Reason is simple, I need to get those values by my side through api. To get this work I made override in desired class: class Carrier extends CarrierCore { public $field_1; public function __construct($id = null, $id_lang = null) { self::$definition['fields']['field_1'] = array('type' => self::TYPE_BOOL, 'validate' => 'isBool'); parent::__construct($id, $id_lang); } } Everything is fine, but I need this solution to be independed from another modules, any modules. What I've tested is that another module wouldn't be able to override constructor or if constructor is alerady overrided I won't be able to install my module. How to acheive it? Ofcourse I can create custom table, but to be able to get its values through API by my side I will have to modify API and override getResources mtehod from WebserviceRequest class and what about if it will be alerady overrided?. How can I solve this problem without any overrides or any other solutions? I only need that my module won't collide with any other modules and its installation will be safe. Regards Edited January 28, 2016 by mdomski (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted January 29, 2016 Share Posted January 29, 2016 You cannot override it again, of course. What you can do is using custom methods from within the modules themselves. Prestashop would load the modules altogether, so that's why they can't overlap. If you want you override to be used only at a module's run time, then use a custom method instead Link to comment Share on other sites More sharing options...
mdomski Posted January 29, 2016 Author Share Posted January 29, 2016 Yeah I know it's not possible to override the same method multiple times. Using custom methods from other modules is not my point, because I don't need them : ), I just don't want to collide with them while gaining desired funcionality. There should be option to add fields to stock tables (without overrides) and let them to be visible in API or to add own table (like it's possible now) and simply add it to API resources (again without overrides). Maybe I'm missing something? In sum, I'm looking for the best and safe way (not colliding with other modules / no overrides) to add field to stock table (for eg. orders) and get it through API by my side. Another solution would be to create my own table and let it to be visible in API, but as far as I know adding resource to API still needs overrides right? Regards Link to comment Share on other sites More sharing options...
NemoPS Posted January 30, 2016 Share Posted January 30, 2016 Honestly, I fear there is not way to do what you need in a clean way, as the only one would be to modify the core. At least, as far as I know 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