function commerce_autosku_commerce_product_presave in Commerce AutoSKU 7
Implements hook_commerce_product_presave().
File
- ./
commerce_autosku.commerce.inc, line 69 - Contains Drupal Commerce specific hook implementations. Included automatically.
Code
function commerce_autosku_commerce_product_presave($product) {
$settings = commerce_autosku_get_settings($product);
if ($settings) {
if (_commerce_autosku_needs_temporary_sku($product, $settings)) {
$product->sku = _commerce_autosku_get_temporary_sku();
}
elseif (empty($product->sku) || _commerce_autosku_is_temporary_sku($product->sku) || $settings['advanced']['update_existing']) {
// Generate the SKU.
$product->sku = commerce_autosku_generate_sku($product, $settings['pattern'], $settings['advanced']['case']);
}
}
}