sfhbsf Posted November 8, 2015 Share Posted November 8, 2015 Hello I have created a new column in the product table and want now to save to this field through the Product Object Model. My code is $object = new Product(); $object->dm_product_id = $aP[product_id]; $object->price = $aP[price]; $object->id_tax_rules_group = 0; foreach (Language::getLanguages(false) as $lang){ $object->name[$lang['id_lang']] = $aP[product]; $object->description_long[$lang['id_lang']] = $aP[full_description]; $object->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($aP[product]); $object->meta_keywords[$lang['id_lang']] = $aP[product]; } $object->id_manufacturer = 0; $object->id_supplier = 0; $object->quantity = $aP[amount]; $object->minimal_quantity = 1; $object->additional_shipping_cost = $aP[shipping_freight]; $object->wholesale_price = 0; $object->ecotax = 0; $object->width = 0; $object->height = 0; $object->depth = 0; $object->weight = $aP[weight]; $object->out_of_stock = 0; $object->active = 1; $object->id_category_default = 18; $object->category = 18; $object->available_for_order = 1; $object->show_price = 1; $object->on_sale = 0; $object->online_only = 1; if($object->save()) $object->add(); The new variable is dm_product_id. It will not be saved. Can you tell me what exactly I need to change in order that it will be saved? Thank you! Link to comment Share on other sites More sharing options...
sfhbsf Posted November 8, 2015 Author Share Posted November 8, 2015 (edited) Its not showing an error, product is created but the new variable is empty. The add is there so it does add a row if i can not update, if I understand right. Its not throwing an error with your save-code. The quotation marks are not the mistake. The product_ids are not not the same. One is coming from API other from Presta. I guess that the core files must be extended, but how I need to do this? Anyone has the solution? Edited November 8, 2015 by sfhbsf (see edit history) Link to comment Share on other sites More sharing options...
sfhbsf Posted November 8, 2015 Author Share Posted November 8, 2015 Where do i need to add this code in the module? Is this all I need to do, that the variable is automatically saved from the object->save()? Link to comment Share on other sites More sharing options...
sfhbsf Posted November 9, 2015 Author Share Posted November 9, 2015 It works. Thanks. I think I it was i was using public $dm_product_id = 0; or because I used isInt. Now can I add this code to the module? Or only overwrite? Link to comment Share on other sites More sharing options...
sfhbsf Posted November 9, 2015 Author Share Posted November 9, 2015 I was reading somewhere, that overrides are not the method of choice for a module? What I need to do in order to add this to the module? Thank you Link to comment Share on other sites More sharing options...
sfhbsf Posted November 9, 2015 Author Share Posted November 9, 2015 So what is the proper way to do it? Can we not override from within the module folder? This module must become a verified prestashop module in the end. Link to comment Share on other sites More sharing options...
sfhbsf Posted November 9, 2015 Author Share Posted November 9, 2015 The finished module will just contain module and override folder? 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