renaud2263 Posted June 27, 2016 Share Posted June 27, 2016 Hi All, Actually when I create a new product with my PS 1.6.1, I need the reference is the same of the ID (which I don't know at this stage due to the auto-increment. ) So what should be the best way to do that ? Overriding AdminProductController ? The class ? I saw the function add and the hook actionProductSave called. But where is this hook ? Or maybe I have to create a module with this kind of hook : public function hookActionProductSave() { $id = Tools::getValue('id_product'); $product = new Product($id); $product->reference = ($id; $product->save(); } Could you give me some indications ? Thanks ! Link to comment Share on other sites More sharing options...
renaud2263 Posted June 27, 2016 Author Share Posted June 27, 2016 Thanks for your answer, i finally created a module to update the database withe the reference = id. 1 Link to comment Share on other sites More sharing options...
stupidcomputer Posted December 10, 2019 Share Posted December 10, 2019 (edited) On 6/27/2016 at 5:37 PM, renaud2263 said: Thanks for your answer, i finally created a module to update the database withe the reference = id. Hi @renaud2263, please can you share your solution or your custom module? Edited December 10, 2019 by stupidcomputer (see edit history) Link to comment Share on other sites More sharing options...
sanjuv63 Posted November 3, 2022 Share Posted November 3, 2022 On 6/27/2016 at 9:07 PM, renaud2263 said: Thanks for your answer, i finally created a module to update the database withe the reference = id. Hi @renaud2263, please can you share your solution or your custom module? Link to comment Share on other sites More sharing options...
ps8modules Posted November 4, 2022 Share Posted November 4, 2022 Hi. The function for the module is: public function hookActionProductUpdate() { $id = Tools::getValue('id_product'); Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product SET reference = id_product WHERE id_product = '.$id); } 1 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