Images should be uploaded before import, where the Photo/Image field corresponds to the filename of a file that was uploaded. Variations can be specified in a "Variation" column this format: Type:value,value,value eg: Color: red, green, blue , yellow up to 6 other variation columns can be specified by adding a number to the end, eg Variation2,$Variation3
Inheritance: extends CsvBulkLoader
 function testLoad()
 {
     $loader = new ProductBulkLoader('Product');
     $filepath = Director::baseFolder() . '/ecommerce/tests/test_products.csv';
     $file = fopen($filepath, 'r');
     fgetcsv($file);
     // pop header row
     $compareRow = fgetcsv($file);
     $results = $loader->load($filepath);
     // Test that right amount of columns was imported
     //$this->assertEquals(4, $results->Count(), 'Test correct count of imported data');
     // Test that columns were correctly imported
     $obj = DataObject::get_one("Product", "\"Title\" = 'Socks'");
     $this->assertNotNull($obj);
     $this->assertEquals("<p>The comfiest pair of socks you'll ever own.</p>", $obj->Content);
     $this->assertEquals(12, $obj->Price, "Checking price matches.");
     //$this->assertEquals(124, $obj->ID,"Checking ID matches");
     fclose($file);
 }
 public function testLoad()
 {
     $loader = new ProductBulkLoader('Product');
     $ds = DIRECTORY_SEPARATOR;
     $filepath = realpath(__DIR__ . $ds . '..' . $ds . 'test_products.csv');
     $file = fopen($filepath, 'r');
     fgetcsv($file);
     // pop header row
     $compareRow = fgetcsv($file);
     $results = $loader->load($filepath);
     // Test that right amount of columns was imported
     //$this->assertEquals(4, $results->Count(), 'Test correct count of imported data');
     // Test that columns were correctly imported
     $obj = DataObject::get_one("Product", "\"Title\" = 'Socks'");
     $this->assertNotNull($obj, "New product exists");
     $this->assertEquals("<p>The comfiest pair of socks you'll ever own.</p>", $obj->Content, "Content matches");
     $this->assertEquals(12, $obj->BasePrice, "Checking price matches.");
     //$this->assertEquals(124, $obj->ID,"Checking ID matches");
     fclose($file);
     $this->markTestIncomplete('Incomplete');
 }
 protected function processAll($filepath, $preview = false)
 {
     $this->extend('updateColumnMap', $this->columnMap);
     // we have to check for the existence of this in case the stockcontrol module hasn't been loaded
     // and the CSV still contains a Stock column
     self::$hasStockImpl = Object::has_extension('Product', 'ProductStockDecorator');
     $results = parent::processAll($filepath, $preview);
     //After results have been processed, publish all created & updated products
     $objects = new DataObjectSet();
     $objects->merge($results->Created());
     $objects->merge($results->Updated());
     foreach ($objects as $object) {
         if (!$object->ParentID) {
             //set parent page
             if (is_numeric(self::$parentpageid) && DataObject::get_by_id('ProductGroup', self::$parentpageid)) {
                 //cached option
                 $object->ParentID = self::$parentpageid;
             } elseif ($parentpage = DataObject::get_one('ProductGroup', "\"Title\" = 'Products'", '"Created" DESC')) {
                 //page called 'Products'
                 $object->ParentID = self::$parentpageid = $parentpage->ID;
             } elseif ($parentpage = DataObject::get_one('ProductGroup', "\"ParentID\" = 0", '"Created" DESC')) {
                 //root page
                 $object->ParentID = self::$parentpageid = $parentpage->ID;
             } elseif ($parentpage = DataObject::get_one('ProductGroup', "", '"Created" DESC')) {
                 //any product page
                 $object->ParentID = self::$parentpageid = $parentpage->ID;
             } else {
                 $object->ParentID = self::$parentpageid = 0;
             }
         }
         $object->extend('updateImport');
         //could be used for setting other attributes, such as stock level
         $object->writeToStage('Stage');
         $object->publish('Stage', 'Live');
     }
     return $results;
 }