Skip to content

Instantly share code, notes, and snippets.

@muskie9
Created May 11, 2015 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muskie9/19702461da1b7fb4ea4e to your computer and use it in GitHub Desktop.
Save muskie9/19702461da1b7fb4ea4e to your computer and use it in GitHub Desktop.
<?php
class ProductUpdateTask extends BuildTask{
protected $title = 'Product Update Task';
protected $description = 'Update Products to the new class';
protected $enabled = true;
function run($request){
$updateProduct = function($self){
$product = ProductPage::get()->byID($self->ID);
$product->ClassName = 'NestProduct';
$product->write();
$product->doPublish();
echo "<p>{$self->Title} updated to {$self->ClassName}</p>";
};
$products = ProductPage::get();
$products->each($updateProduct);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment