Because Commerce doesn't support Twig product title formatting right now, I built a custom plugin to automatically update the title field upon save of a product.
Here is the part from the plugin where I am hooking into the commerce_products.onBeforeSaveProduct
event:
craft()->on('commerce_products.onBeforeSaveProduct', function(Event $event) {
$product = $event->params['product'];
if (count($product->collection))
{
$collection = $product->collection[0]->title;
$titlePieces[] = $collection;
}
$modelNumber = $product->modelNumber;
$titlePieces[] = $modelNumber;
$titleSuffix = $product->titleSuffix;
$titlePieces[] = $titleSuffix;
$product->getContent()->title = implode(' ', $titlePieces);
});
All that works great when I manually edit a product, but we have about 500 products in the system right now, and nobody really wants to open up every entry and manually save it. The hope was that we could do something in the CP to trigger an event to re-save all product entries.
I went into the Commerce settings for each Product Type and re-saved the settings, which did trigger a "Resaving Furniture products" task. But, that didn't appear to update the title field for all the products.
Any other ideas on how I could avoid manually re-saving all entries?