wakabayashi Posted January 19, 2017 Share Posted January 19, 2017 I have problems with updating a Product (custom fields) in Prestashop. I followed the tutorial: http://blog.belvg.com/how-to-create-a-custom-product-tab-in-prestashop.html It works quite fine, when I save a product the normal way. But Prestashop 1.6 has an autosave function, when changing stock or prices. This makes my custom fields empty. By trial & error I found out, that my hookActionProductUpdate function causes the problem, but I dont know why: public function hookActionProductUpdate($params) { $id_product = Tools::getValue('id_product'); $sampleObj = Belvg_Sample::loadByIdProduct($id_product); $sampleObj->lagerplatz = Tools::getValue('lagerplatz'); $sampleObj->artnrlfr = Tools::getValue('artnrlfr'); $sampleObj->archiv = Tools::getValue('archiv'); $sampleObj->bundle = Tools::getValue('bundle'); $sampleObj->beschrieb = Tools::getValue('beschrieb'); $sampleObj->oldartnr = Tools::getValue('oldartnr'); $sampleObj->id_product = $id_product; if(!empty($sampleObj) && isset($sampleObj->id)){ $sampleObj->update(); } else { $sampleObj->add(); } } What is wrong with it? Thanks in advance! Link to comment Share on other sites More sharing options...
wakabayashi Posted January 19, 2017 Author Share Posted January 19, 2017 I usually add an hidden field in the form<input type="hidden" name="CUSTOM_TAB_LOADED" value="1"> Then in the update functionif(!Tools::getValue('CUSTOM_TAB_LOADED'))return; this way you only save it if it was loaded. Got this answer in stackoverflow. It's a nice trick! Link to comment Share on other sites More sharing options...
dharmendra virasat Posted June 11, 2019 Share Posted June 11, 2019 i have a same problem plz reply what can i do ? Link to comment Share on other sites More sharing options...
phinq1910 Posted June 11, 2019 Share Posted June 11, 2019 Did you got logs? Whats that? Did you defined "Belvg_Sample" object? 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