function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // $fields->addFieldToTab('Root.Main', $f = new TextField($name = 'Description'));
     $fields->addFieldToTab('Root.Main', LiteralField::create('OldID', "<b>OLDID:</b>" . $this->OldID));
     $fields->addFieldToTab('Root.Main', DateField::create('Sold', ' Sold')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', TextField::create('Quantity'));
     $fields->addFieldToTab('Root.Main', TextareaField::create('Comment'));
     $fields->addFieldToTab('Root.Main', TextField::create('SellPrice'));
     $fields->addFieldToTab('Root.Main', TextField::create('BuyPrice'));
     $fields->addFieldToTab('Root.Main', DateField::create('SoldDate')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('Sold'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('ForSaleInWebshop'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('OnHold'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('ShowInList'));
     //        $fields->addFieldToTab('Root.Main', S::create('Deal'));  TODO!!!
     $fields->addFieldToTab('Root.Main', DropdownField::create('DealID', 'Deal', Deal::get()->map('ID', 'Title'))->setEmptyString('(Select one)'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('InStock'));
     $fields->addFieldToTab('Root.Main', CheckboxField::create('IsForSale'));
     $fields->addFieldToTab('Root.Main', TextField::create('Quantity'));
     $fields->addFieldToTab('Root.Main', TextField::create('Showdate'));
     $fields->addFieldToTab('Root.Main', TextField::create('IndateStamp'));
     $fields->addFieldToTab('Root.Main', TextField::create('SC_FK'));
     $fields->addFieldToTab('Root.Main', TextField::create('DatumCode'));
     $fields->addFieldToTab('Root.Main', TextField::create('OriginalCode'));
     $fields->addFieldToTab('Root.Main', TextField::create('SortKey'));
     $fields->addFieldToTab('Root.Main', TextField::create('AllRow'));
     $fields->addFieldToTab('Root.Main', TextField::create('OldCat'));
     $fields->addFieldToTab('Root.Main', DateField::create('SortDate')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', DateField::create('NewOfDate')->setConfig('showcalendar', true));
     $fields->addFieldToTab('Root.Main', NumericField::create('NewSubCatFK'));
     //$fields->addFieldToTab('Root.Main', UploadField::create('Photos'));
     $imageField = new SortableUploadField('Photos', 'Images');
     $fields->addFieldToTab('Root.Main', $imageField);
     $map = SubCategoryPage::get()->map("ID", "ParentAndTitle")->toArray();
     //            Debug::show($map);
     $CategoryPages = new MultiSelect2Field('SubCategoryPages', 'SubCategoryPages', $map, null, 0, true);
     $fields->addFieldToTab('Root.SubCategoryPages', $CategoryPages);
     #LINKS
     $gridFieldConfig1 = GridFieldConfig::create()->addComponent(new GridFieldToolbarHeader())->addComponent(new GridFieldAddNewButton('toolbar-header-right'))->addComponent(new GridFieldSortableHeader())->addComponent(new GridFieldDataColumns())->addComponent(new GridFieldPaginator(50))->addComponent(new GridFieldEditButton())->addComponent(new GridFieldDeleteAction())->addComponent(new GridFieldDetailForm());
     $fields->addFieldToTab('Root.ProductLinks', $grid = new GridField('ProductLinks', 'Links', $this->ProductLinks(), $gridFieldConfig1));
     //        new GridField
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 private function readSubCategories()
 {
     $row = 0;
     if (($handle = fopen("../mysite/code/NewSubCats.csv", "r")) !== FALSE) {
         while (($dat = fgetcsv($handle, 1000, ",")) !== FALSE) {
             //                $num = count($dat);
             $row++;
             if ($row > 1) {
                 Debug::show($dat);
                 $SC = new SubCategoryPage();
                 #! hitta ID på den som har OLDMC $dat[2];
                 $MC = DataObject::get("MainCategoryPage")->filter(array("OldMCID" => $dat[2]))->first();
                 //Debug::show($Prod);
                 $SC->ParentID = $MC->ID;
                 $SC->OldSCID = $dat[0];
                 $SC->OldMCID = $dat[2];
                 $SC->Title = $dat[1];
                 $SC->Title_sv = $dat[4];
                 $SC->write();
                 $SC->writeToStage('Stage');
                 $SC->publish('Stage', 'Live');
                 Debug::show($SC);
             }
         }
     }
 }