Source of file CommerceWriteItemsTask.php
Size: 0,947 Bytes - Last Modified: 2021-12-24T05:16:32+00:00
/var/www/docs.ssmods.com/process/src/tasks/CommerceWriteItemsTask.php
1234567891011121314151617181920212223242526272829303132333435363738394041 | <?php /** * Loops through all products and Categories, and sets their URL Segments, if * they do not already have one * * @package commerce * @subpackage tasks */ class CommerceWriteItemsTask extends BuildTask { protected $title = 'Write All Commerce Items'; protected $description = 'Loop through all products and product categories and re-save them.'; public function run($request) { $products = 0; $categories = 0; // First load all products $items = Product::get(); foreach($items as $item) { // Just write product, on before write should deal with the rest $item->write(); $products++; } // Then all categories $items = ProductCategory::get(); foreach($items as $item) { // Just write category, on before write should deal with the rest $item->write(); $categories++; } echo "Wrote $products products and $categories categories.\n"; } } |