/**
  * Builds the DataObject of filtered products
  *
  * @return DataList
  * 
  * @author Sebastian Diel <sdiel@πixeltricks.de>
  * @since 23.09.2014
  */
 public function buildSearchResultProducts()
 {
     $searchResultProducts = $this->searchResultProducts;
     $productsPerPage = $this->getProductsPerPageSetting();
     $SQL_start = $this->getSqlOffset();
     $searchQuery = $this->getSearchQuery();
     $searchTerms = explode(' ', $searchQuery);
     $filter = '';
     $useExtensionResults = $this->extend('updateSearchResult', $searchResultProducts, $searchQuery, $SQL_start);
     if (empty($useExtensionResults)) {
         $this->listFilters['original'] = sprintf('
            "SilvercartProduct"."SilvercartProductGroupID" IS NOT NULL AND
            "SilvercartProduct"."SilvercartProductGroupID" > 0 AND
            "SPGPL"."ID" > 0 AND
            "SilvercartProduct"."isActive" = 1 AND (
                 (
                     "SilvercartProductLanguage"."Title" LIKE \'%s%%\' OR
                     "SilvercartProductLanguage"."ShortDescription" LIKE \'%s%%\' OR
                     "SilvercartProductLanguage"."LongDescription" LIKE \'%s%%\' OR
                     "SilvercartProductLanguage"."Title" LIKE \'%%%s%%\' OR
                     "SilvercartProductLanguage"."ShortDescription" LIKE \'%%%s%%\' OR
                     "SilvercartProductLanguage"."LongDescription" LIKE \'%%%s%%\'
                 ) OR
                "SilvercartProductLanguage"."MetaKeywords" LIKE \'%%%s%%\' OR
                "SilvercartProduct"."ProductNumberShop" LIKE \'%%%s%%\' OR
                "SilvercartProduct"."EANCode" LIKE \'%%%s%%\' OR
                 STRCMP(
                     SOUNDEX("SilvercartProductLanguage"."Title"), SOUNDEX(\'%s\')
                 ) = 0
             )
             ', $searchQuery, $searchQuery, $searchQuery, $searchQuery, $searchQuery, $searchQuery, $searchQuery, $searchQuery, $searchQuery, $searchQuery);
         if (count(self::$registeredFilterPlugins) > 0) {
             foreach (self::$registeredFilterPlugins as $registeredPlugin) {
                 $pluginFilters = $registeredPlugin->filter();
                 if (is_array($pluginFilters)) {
                     $this->listFilters = array_merge($this->listFilters, $pluginFilters);
                 }
             }
         }
         $this->extend('updateListFilters', $this->listFilters, $searchTerms);
         foreach ($this->listFilters as $listFilter) {
             if (empty($filter)) {
                 $filter = $listFilter;
             } else {
                 if (strpos(trim($listFilter), 'AND') !== 0 && strpos(trim($listFilter), 'OR') !== 0) {
                     $listFilter = 'AND ' . $listFilter;
                 }
                 $filter = '(' . $filter . ') ' . $listFilter;
             }
         }
         if (SilvercartProduct::defaultSort() == 'relevance') {
             $sort = '';
         } else {
             $sort = SilvercartProduct::defaultSort();
         }
         $searchResultProductsRaw = SilvercartProduct::getProducts($filter, $sort, array(array('table' => 'SilvercartProductGroupPage_Live', 'on' => '"SPGPL"."ID" = "SilvercartProduct"."SilvercartProductGroupID"', 'alias' => 'SPGPL')));
         $searchResultProducts = new PaginatedList($searchResultProductsRaw, $this->getRequest());
         $searchResultProducts->setPageStart($SQL_start);
         $searchResultProducts->setPageLength($productsPerPage);
     }
     $this->searchResultProducts = $searchResultProducts;
     $this->totalNumberOfProducts = $searchResultProducts->count();
     $searchQueryObject = SilvercartSearchQuery::get_by_query(Convert::raw2sql($searchQuery));
     if ($searchQueryObject->Hits != $this->totalNumberOfProducts) {
         $searchQueryObject->Hits = $this->totalNumberOfProducts;
         $searchQueryObject->write();
     }
     return $this->searchResultProducts;
 }
 public function DataObjectsToBeUpdated()
 {
     if (!self::$objects) {
         $table = $this->SecureTableToBeUpdated();
         $field = $this->SecureFieldToBeUpdated();
         $where = '';
         if (isset($this->requestParams["where"]) && $this->requestParams["where"]) {
             $where = urldecode($this->requestParams["where"]);
         }
         $sort = '';
         if (isset($this->requestParams["sort"]) && $this->requestParams["sort"]) {
             $sort = urldecode($this->requestParams["sort"]);
         }
         $titleField = 'Title';
         if (isset($this->requestParams["titlefield"]) && $this->requestParams["titlefield"]) {
             $titleField = urldecode($this->requestParams["titlefield"]);
         }
         $start = 0;
         if (isset($this->requestParams["start"])) {
             $start = intval($this->requestParams["start"]);
         }
         if (isset($_GET["debug"])) {
             print_r("SELECT * FROM {$table} {$where} SORT BY {$sort} LIMIT {$start}, " . Config::inst()->get("DataObjectOneFieldUpdateController", "page_size"));
         }
         $dataList = $table::get()->where($where)->sort($sort);
         $objects = new PaginatedList($dataList, $this->request);
         $objects->setPageLength(Config::inst()->get("DataObjectOneFieldUpdateController", "page_size"));
         $arrayList = new ArrayList();
         if ($objects->count()) {
             $testObject = $objects->first();
             if (!$testObject->canEdit()) {
                 Security::permissionFailure($this, _t('Security.PERMFAILURE', ' This page is secured and you need administrator rights to access it. Enter your credentials below and we will send you right along.'));
                 return;
             }
             foreach ($objects as $obj) {
                 $obj->FormField = $obj->dbObject($field)->scaffoldFormField();
                 $obj->FormField->setName($obj->ClassName . "/" . $obj->ID);
                 //3.0TODO Check that I work vvv.
                 $obj->FormField->addExtraClass("updateField");
                 $obj->FieldToBeUpdatedValue = $obj->{$field};
                 $obj->FormField->setValue($obj->{$field});
                 $arrayList->push(new ArrayData(array("FormField" => $obj->FormField, "MyTitle" => $obj->{$titleField}())));
             }
         }
         self::$objects = $arrayList;
         self::$objects_without_field = $objects;
     }
     return self::$objects;
 }