There is no interface to use this module for products that are not created using Product UI. I have a product in my custom module as below:

/**
 * Implements hook_commerce_product_type_info().
 */
function custom_product_commerce_product_type_info() {
  return array(
    'room' => array(
      'type' => 'custom_product',
      'name' => t('Custom Product'),
      'description' => t('Custom product available for purchase.'),
      'revision' => '1',
    ),
  );
}

Currently autosku module does not provide any way to add sku tokens to a product created like above. I can write a patch if pointed to the right direction.

Comments

rbayliss’s picture

There are now two ways to do this. You can either define the autosku settings in your hook_commerce_product_type_info(), like so:

$types['product'] = array(
  'product' => array(
    'type' => 'product',
    'name' => 'Product',
    'description' => 'A basic product type.',
    'help' => '',
    'revision' => '1',
    'module' => 'commerce_product_ui',
    'autosku' => array(
      'pattern' => '[commerce-product:product-id]',
      'advanced' => array(
        'update_existing' => 1,
        'hide_sku' => 1,
        'case' => '0',
      ),
    ),
  ),
); 

The recommended way to do it though, is to use hook_default_commerce_autosku_patterns() (this is just using CTools export api). Here's an example of that:

function mymodule_default_commerce_autosku_patterns() {
  $export = array();

  $commerce_autosku_patterns = new stdClass();
  $commerce_autosku_patterns->disabled = FALSE; /* Edit this to true to make a default commerce_autosku_patterns disabled initially */
  $commerce_autosku_patterns->api_version = 1;
  $commerce_autosku_patterns->product_type = 'test_product_type';
  $commerce_autosku_patterns->pattern = '[commerce-product:product-id]';
  $commerce_autosku_patterns->advanced = array(
    'update_existing' => 1,
    'hide_sku' => 1,
    'case' => '0',
  );
  $export['test_product_type'] = $commerce_autosku_patterns;

  return $export;
} 

Just one note if you're going to use the second method - I just added support for that today, so you'll need the latest dev version.

rbayliss’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

cocoshogo’s picture

Issue summary: View changes

Does this still work? Can I just add #1 (second suggestion) to my themes template.php ?