Source of file CatalogueWriteAllItemsTask.php
Size: 0,971 Bytes - Last Modified: 2021-12-24T05:16:22+00:00
/var/www/docs.ssmods.com/process/src/tasks/CatalogueWriteAllItemsTask.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 CatalogueWriteAllItemsTask extends BuildTask { protected $title = 'Write All Products and Categories'; 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 = CatalogueProduct::get(); foreach($items as $item) { // Just write product, on before write should deal with the rest $item->write(); $products++; } // Then all categories $items = CatalogueCategory::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"; } } |