/** * when doing the first dev/build, the record will be added as testing product */ function requireDefaultRecords() { parent::requireDefaultRecords(); $product1 = DataObject::get_one('ProductObject', "\"Title\" = 'Daft Robot'"); if (!($product1 && $product1->exists())) { $product1 = new ProductObject(); $product1->Title = 'Daft Robot'; $product1->Description = <<<HTML \t\t\t<p>DVD, 2010<br />Striped Silver Pictures</p> \t\t\t<p>A stellar example of the type of product you might want to sell on your site.</p> HTML; $productImage1 = DataObject::get_one('ProductImage', "\"Name\" = 'daft-robot.png'"); if (!($productImage1 && $productImage1->exists())) { $uploadfolder = Folder::findOrMake("Uploads"); $command = "cp ../payment-test/templates/Images/daft-robot.png ../" . $uploadfolder->Filename; `{$command}`; $productImage1 = new ProductImage(array('ClassName' => 'ProductImage')); $productImage1->Name = 'daft-robot.png'; $productImage1->Title = 'daft-robot'; $productImage1->Filename = 'assets/Uploads/daft-robot.png'; $productImage1->ParentID = $uploadfolder->ID; $productImage1->OwnerID = Member::currentUserID(); $productImage1->write(); } $product1->ImageID = $productImage1->ID; $product1->Amount->Amount = '8.99'; $product1->Amount->Currency = 'USD'; $product1->write(); DB::alteration_message('product example \'Daft Robot\'', 'created'); } $product2 = DataObject::get_one('ProductObject', "\"Title\" = 'Bloody Knife'"); if (!($product2 && $product2->exists())) { $product2 = new ProductObject(); $product2->Title = 'Bloody Knife'; $product2->Description = <<<HTML \t\t\t<p>DVD, 1978<br />SilverSplatter Films</p> \t\t\t<p>A terrifying cult classic that has inspired many horror movies.</p> HTML; $productImage2 = DataObject::get_one('ProductImage', "\"Name\" = 'bloody-knife.png'"); if (!($productImage2 && $productImage2->exists())) { $uploadfolder = Folder::findOrMake("Uploads"); $command = "cp ../payment-test/templates/Images/bloody-knife.png ../" . $uploadfolder->Filename; `{$command}`; $productImage2 = new ProductImage(array('ClassName' => 'ProductImage')); $productImage2->Name = 'bloody-knife.png'; $productImage2->Title = 'bloody-knife'; $productImage2->Filename = 'assets/Uploads/bloody-knife.png'; $productImage2->ParentID = $uploadfolder->ID; $productImage2->OwnerID = Member::currentUserID(); $productImage2->write(); } $product2->ImageID = $productImage2->ID; $product2->Amount->Amount = '19.99'; $product2->Amount->Currency = 'NZD'; $product2->write(); DB::alteration_message('product example \'Blood Knife\'', 'created'); } }