/**
  * standard SS method
  * @return FieldList
  */
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     //dirty hack to show images!
     $fields->addFieldToTab('Root.Images', Product_ProductImageUploadField::create('Image', _t('Product.IMAGE', 'Product Group Image')));
     //number of products
     $calculatedNumberOfProductsPerPage = $this->MyNumberOfProductsPerPage();
     $numberOfProductsPerPageExplanation = $calculatedNumberOfProductsPerPage != $this->NumberOfProductsPerPage ? _t("ProductGroup.CURRENTLVALUE", "Current value: ") . $calculatedNumberOfProductsPerPage . " " . _t("ProductGroup.INHERITEDFROMPARENTSPAGE", " (inherited from parent page because the current page is set to zero)") : "";
     $fields->addFieldToTab('Root', Tab::create('ProductDisplay', $productsToShowField = DropdownField::create("LevelOfProductsToShow", _t("ProductGroup.PRODUCTSTOSHOW", "Products to show"), $this->showProductLevels), HeaderField::create("WhatProductsAreShown", _t("ProductGroup.WHATPRODUCTSSHOWN", _t("ProductGroup.OPTIONSSELECTEDBELOWAPPLYTOCHILDGROUPS", "Inherited options"))), $numberOfProductsPerPageField = NumericField::create("NumberOfProductsPerPage", _t("ProductGroup.PRODUCTSPERPAGE", "Number of products per page"))));
     $numberOfProductsPerPageField->setRightTitle($numberOfProductsPerPageExplanation);
     if ($calculatedNumberOfProductsPerPage && !$this->NumberOfProductsPerPage) {
         $this->NumberOfProductsPerPage = null;
         $numberOfProductsPerPageField->setAttribute("placeholder", $calculatedNumberOfProductsPerPage);
     }
     //sort
     $sortDropdownList = $this->getUserPreferencesOptionsForDropdown("SORT");
     if (count($sortDropdownList) > 1) {
         $sortOrderKey = $this->getMyUserPreferencesDefault("SORT");
         if ($this->DefaultSortOrder == "inherit") {
             $actualValue = " (" . (isset($sortDropdownList[$sortOrderKey]) ? $sortDropdownList[$sortOrderKey] : _t("ProductGroup.ERROR", "ERROR")) . ")";
             $sortDropdownList["inherit"] = _t("ProductGroup.INHERIT", "Inherit") . $actualValue;
         }
         $fields->addFieldToTab("Root.ProductDisplay", $defaultSortOrderField = DropdownField::create("DefaultSortOrder", _t("ProductGroup.DEFAULTSORTORDER", "Default Sort Order"), $sortDropdownList));
         $defaultSortOrderField->setRightTitle(_t("ProductGroup.INHERIT_RIGHT_TITLE", "Inherit means that the parent page value is used - and if there is no relevant parent page then the site's default value is used."));
     }
     //filter
     $filterDropdownList = $this->getUserPreferencesOptionsForDropdown("FILTER");
     if (count($filterDropdownList) > 1) {
         $filterKey = $this->getMyUserPreferencesDefault("FILTER");
         if ($this->DefaultFilter == "inherit") {
             $actualValue = " (" . (isset($filterDropdownList[$filterKey]) ? $filterDropdownList[$filterKey] : _t("ProductGroup.ERROR", "ERROR")) . ")";
             $filterDropdownList["inherit"] = _t("ProductGroup.INHERIT", "Inherit") . $actualValue;
         }
         $fields->addFieldToTab("Root.ProductDisplay", $defaultFilterField = DropdownField::create("DefaultFilter", _t("ProductGroup.DEFAULTFILTER", "Default Filter"), $filterDropdownList));
         $defaultFilterField->setRightTitle(_t("ProductGroup.INHERIT_RIGHT_TITLE", "Inherit means that the parent page value is used - and if there is no relevant parent page then the site's default value is used."));
     }
     //display style
     $displayStyleDropdownList = $this->getUserPreferencesOptionsForDropdown("DISPLAY");
     if (count($displayStyleDropdownList) > 2) {
         $displayStyleKey = $this->getMyUserPreferencesDefault("DISPLAY");
         if ($this->DisplayStyle == "inherit") {
             $actualValue = " (" . (isset($displayStyleDropdownList[$displayStyleKey]) ? $displayStyleDropdownList[$displayStyleKey] : _t("ProductGroup.ERROR", "ERROR")) . ")";
             $displayStyleDropdownList["inherit"] = _t("ProductGroup.INHERIT", "Inherit") . $actualValue;
         }
         $fields->addFieldToTab("Root.ProductDisplay", DropdownField::create("DisplayStyle", _t("ProductGroup.DEFAULTDISPLAYSTYLE", "Default Display Style"), $displayStyleDropdownList));
     }
     if ($this->EcomConfig()->ProductsAlsoInOtherGroups) {
         if (!$this instanceof ProductGroupSearchPage) {
             $fields->addFieldsToTab('Root.OtherProductsShown', array(HeaderField::create('ProductGroupsHeader', _t('ProductGroup.OTHERPRODUCTSTOSHOW', 'Other products to show ...')), $this->getProductGroupsTable()));
         }
     }
     return $fields;
 }
 /**
  * Standard SS Method.
  */
 function getCMSFields()
 {
     //prevent calling updateSettingsFields extend function too early
     //$siteTreeFieldExtensions = $this->get_static('SiteTree','runCMSFieldsExtensions');
     //$this->disableCMSFieldsExtensions();
     $fields = parent::getCMSFields();
     if ($this->Config()->get("add_data_to_meta_description_for_search")) {
         $fields->removeByName("MetaDescription");
     }
     //if($siteTreeFieldExtensions) {
     //$this->enableCMSFieldsExtensions();
     //}
     $fields->replaceField('Root.Main', $htmlEditorField = new HTMLEditorField('Content', _t('Product.DESCRIPTION', 'Product Description')));
     $htmlEditorField->setRows(3);
     $fields->addFieldToTab('Root.Main', new TextField('ShortDescription', _t('Product.SHORT_DESCRIPTION', 'Short Description')), "Content");
     //dirty hack to show images!
     $fields->addFieldToTab('Root.Images', $uploadField = new Product_ProductImageUploadField('Image', _t('Product.IMAGE', 'Product Image')));
     $uploadField->setCallingClass("Product");
     $fields->addFieldToTab('Root.Images', $this->getAdditionalImagesField());
     $fields->addFieldToTab('Root.Images', $this->getAdditionalImagesMessage());
     $fields->addFieldToTab('Root.Details', new ReadonlyField('FullName', _t('Product.FULLNAME', 'Full Name')));
     $fields->addFieldToTab('Root.Details', new ReadOnlyField('FullSiteTreeSort', _t('Product.FULLSITETREESORT', 'Full sort index')));
     $fields->addFieldToTab('Root.Details', $allowPurchaseField = new CheckboxField('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased')));
     $config = $this->EcomConfig();
     if ($config && !$config->AllowFreeProductPurchase) {
         $price = $this->getCalculatedPrice();
         if ($price == 0) {
             $link = $config->CMSEditLink();
             $allowPurchaseField->setDescription(_t("Product.DO_NOT_ALLOW_FREE_PRODUCTS_TO_BE_PURCHASED", "NB: Allow Purchase + zero price is not allowed.  Change the <a href=\"{$link}\">Shop Settings</a> to allow a zero price product purchases or set price on this product."));
         }
     }
     $fields->addFieldToTab('Root.Details', new CheckboxField('FeaturedProduct', _t('Product.FEATURED', 'Featured Product')));
     $fields->addFieldToTab('Root.Details', new NumericField('Price', _t('Product.PRICE', 'Price'), '', 12));
     $fields->addFieldToTab('Root.Details', new TextField('InternalItemID', _t('Product.CODE', 'Product Code'), '', 30));
     if ($this->EcomConfig()->ProductsHaveWeight) {
         $fields->addFieldToTab('Root.Details', new NumericField('Weight', _t('Product.WEIGHT', 'Weight')));
     }
     if ($this->EcomConfig()->ProductsHaveModelNames) {
         $fields->addFieldToTab('Root.Details', new TextField('Model', _t('Product.MODEL', 'Model')));
     }
     if ($this->EcomConfig()->ProductsHaveQuantifiers) {
         $fields->addFieldToTab('Root.Details', new TextField('Quantifier', _t('Product.QUANTIFIER', 'Quantifier (e.g. per kilo, per month, per dozen, each)')));
     }
     $fields->addFieldToTab('Root.Main', new LiteralField('AddToCartLink', "<p class=\"message good\"><a href=\"" . $this->AddLink() . "\">" . _t("Product.ADD_TO_CART", "add to cart") . "</a></p>"));
     if ($this->EcomConfig()->ProductsAlsoInOtherGroups) {
         $fields->addFieldsToTab('Root.AlsoShowHere', array(new HeaderField('ProductGroupsHeader', _t('Product.ALSOSHOWSIN', 'Also shows in ...')), $this->getProductGroupsTableField()));
     }
     //if($siteTreeFieldExtensions) {
     //$this->extend('updateSettingsFields', $fields);
     //}
     return $fields;
 }