Esempio n. 1
0
 public function runOperation()
 {
     global $DB;
     switch (ToUpper($DB->type)) {
         case 'MYSQL':
             $tableName = 'b_catalog_discount';
             break;
         case 'MSSQL':
             $tableName = 'B_CATALOG_DISCOUNT';
             break;
         case 'ORACLE':
             $tableName = 'B_CATALOG_DISCOUNT';
             break;
     }
     $emptyList = true;
     CTimeZone::Disable();
     $filter = array('TYPE' => CCatalogProductSet::TYPE_SET, 'SET_ID' => 0);
     if ($this->lastID > 0) {
         $filter['>ID'] = $this->lastID;
     }
     $topCount = $this->maxOperationCounter > 0 ? array('nTopCount' => $this->maxOperationCounter) : false;
     $productSetsIterator = CCatalogProductSet::getList(array('ID' => 'ASC'), array('TYPE' => CCatalogProductSet::TYPE_SET, 'SET_ID' => 0, '>ID' => $this->lastID), false, $topCount, array('ID', 'OWNER_ID', 'ITEM_ID', 'MODIFIED_BY', 'TIMESTAMP_X'));
     while ($productSet = $productSetsIterator->Fetch()) {
         $emptyList = false;
         $productSet['MODIFIED_BY'] = (int) $productSet['MODIFIED_BY'];
         if ($productSet['MODIFIED_BY'] == 0) {
             $productSet['MODIFIED_BY'] = false;
         }
         CCatalogProductSet::recalculateSet($productSet['ID'], $productSet['ITEM_ID']);
         $arTimeFields = array('~TIMESTAMP_X' => $DB->CharToDateFunction($productSet['TIMESTAMP_X'], "FULL"), '~MODIFIED_BY' => $productSet['MODIFIED_BY']);
         $strUpdate = $DB->PrepareUpdate($tableName, $arTimeFields);
         if (!empty($strUpdate)) {
             $strQuery = "update " . $tableName . " set " . $strUpdate . " where ID = " . $productSet['ID'];
             $DB->Query($strQuery, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
         $this->allOperationCounter++;
         $this->lastID = $productSet['ID'];
         if ($this->maxExecutionTime > 0 && time() - $this->startOperationTime > $this->maxExecutionTime) {
             break;
         }
     }
     CTimeZone::Enable();
     if ($emptyList) {
         $this->finishOperation = true;
     }
 }