/**
  * Returns the form fields for this form
  *
  * @param bool $withUpdate Call the method with decorator updates or not?
  * 
  * @return array
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 13.09.2013
  */
 public function getFormFields($withUpdate = true)
 {
     if (!array_key_exists('SortOrder', $this->formFields)) {
         $productsPerPage = $this->controller->getProductsPerPageSetting();
         if ($productsPerPage == SilvercartConfig::getProductsPerPageUnlimitedNumber()) {
             $productsPerPage = 0;
         }
         $product = singleton('SilvercartProduct');
         $sortableFrontendFields = $product->sortableFrontendFields();
         $sortableFrontendFieldValues = array_keys($sortableFrontendFields);
         $sortableFrontendFieldValues = array_flip($sortableFrontendFieldValues);
         if (!array_key_exists($product->getDefaultSort(), $sortableFrontendFieldValues)) {
             $sortableFrontendFieldValues[$product->getDefaultSort()] = 0;
         }
         $sortOrder = $sortableFrontendFieldValues[$product->getDefaultSort()];
         $sortableFrontendFieldsForDropdown = array_values($sortableFrontendFields);
         asort($sortableFrontendFieldsForDropdown);
         $this->formFields = array('SortOrder' => array('type' => 'DropdownField', 'title' => _t('SilvercartProductGroupPageSelector.SORT_ORDER'), 'value' => $sortableFrontendFieldsForDropdown, 'selectedValue' => $sortOrder, 'checkRequirements' => array()));
         $productsPerPageOptions = SilvercartConfig::getProductsPerPageOptions();
         if (!empty($productsPerPageOptions)) {
             $this->formFields['productsPerPage'] = array('type' => 'DropdownField', 'title' => _t('SilvercartProductGroupPageSelector.PRODUCTS_PER_PAGE'), 'value' => SilvercartConfig::getProductsPerPageOptions(), 'selectedValue' => $productsPerPage, 'checkRequirements' => array());
         } else {
             $this->formFields['productsPerPage'] = array('type' => 'HiddenField', 'value' => SilvercartConfig::getProductsPerPageDefault());
         }
     }
     return parent::getFormFields($withUpdate = true);
 }
 /**
  * Get the customer's configuration object or create one if it doesn't
  * exist yet.
  *
  * @return SilvercartCustomerConfig
  *
  * @author Sascha Koehler <*****@*****.**>
  * @since 23.08.2011
  */
 public function getSilvercartCustomerConfig()
 {
     if (!$this->owner->SilvercartCustomerConfigID || !DataObject::get_by_id('SilvercartCustomerConfig', $this->owner->SilvercartCustomerConfigID)) {
         $silvercartCustomerConfig = new SilvercartCustomerConfig();
         $silvercartCustomerConfig->MemberID = $this->owner->ID;
         $silvercartCustomerConfig->productsPerPage = SilvercartConfig::getProductsPerPageDefault();
         $silvercartCustomerConfig->write();
         $this->owner->SilvercartCustomerConfigID = $silvercartCustomerConfig->ID;
         $this->owner->write();
     }
     return $this->owner->SilvercartCustomerConfig();
 }