No replies
GANDULE's picture
Joined: 04/08/2014
Juice: 4
Was this information Helpful?

I want insert a new product programmatically.

Then i write this code:

  $node = new stdClass();
  $node->type = 'product';

  node_object_prepare($node); // This sets up all the default node fields so we don't accidentally leave something off.

  // Copy over all the existing settings from Drupal 5.
  $node->uid = 1;
  $node->title = 'Prodottoprova';

  // Set Ubercart variables
  $node->model = "sal111111";//$_POST["CodiceArticolo"]; // the SKU is a required field, so I generated a SKU based on the node title
  $node->sell_price = "5.00"; //$_POST["Prezzo"];
  $node->default_qty = 1;
  $node->weight_units = "pz";


$foo = taxonomy_get_term_by_name('Salumi', 'catalog');


So, the product is insert corretly at the database; but I want set the Taxonomy and other custom field.

Have you got any suggestion?

Thanks a lot!