Discussions

[SOLVED] Programagical types and products.

Hi guys,

I origonally posted up in the drupal module forums, but it was suggested i posted here so, following on from the origonal question found here:

https://drupal.org/node/2065989

Im getting -

FieldException: Attempt to create an instance of field commerce_price without a bundle. in field_create_instance() (line 481 of /home/signdes/public_html/modules/field/field.crud.inc).
The website encountered an unexpected error. Please try again later.

When installing with this in the install hook:

/**
* Implements hook_install().
*/
function cg_commerce_signs_install() {
  drupal_static_reset();
  commerce_product_configure_product_types();

  $product_type = commerce_product_ui_product_type_new();

  $product_type['type'] = 'commerce_sign';
  $product_type['name'] = t('Commerce Sign');
  $product_type['description'] = t('A commerce sign product type.');
  $product_type['is_new'] = TRUE;

  commerce_product_ui_product_type_save($product_type, TRUE);
}

My understanding of this error is because the product type is missing, so the question for now is how do i programatically create a product type on install? (essentually a content type)

Posted: Aug 15, 2013

Comments