Programmatically add new product
The values for sku , title and commerce_price are good.
$form2_id = 'commerce_product_ui_product_form';
$form2_state['values'] = array(
'sku' => $form['title']['#value'].'_'.rand(1,10000),
'title' => $form['title']['#value'],
'commerce_price' => $form['auction_starting_price']['und'][0]['amount']['#value'],
'op' => t('Save Product')
);
drupal_form_submit($form2_id, $form2_state);
$form_errors = form_get_errors();
drupal_set_message('Form errors = '.$form_errors);
I get no errors but lots of warnings... and the data is not saved to the db.
call_user_func_array() expects parameter 1 to be a valid callback, function 'commerce_product_product_form' not found or invalid function name in drupal_retrieve_form() (line 799 of /home/quicksyl/public_html/live/includes/form.inc). -
Comments
http://xandeadx.ru/blog
http://xandeadx.ru/blog/drupal/690