Jump to content

Save a new variable to the product object model


sfhbsf

Recommended Posts

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

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 by sfhbsf (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...