예제 #1
0
 protected function getDiscountHandlers($discountList)
 {
     $result = array();
     if (!empty($discountList) && is_array($discountList)) {
         $moduleList = Internals\DiscountModuleTable::getByDiscount($discountList);
         if (!empty($moduleList)) {
             foreach ($moduleList as $discount => $discountModule) {
                 $result[$discount] = array('MODULES' => $discountModule, 'EXT_FILES' => array());
             }
             unset($discount, $discountModule, $moduleList);
         }
     }
     return $result;
 }
예제 #2
0
 /**
  * Default onAfterDelete handler. Absolutely necessary.
  *
  * @param Main\Entity\Event $event		Event object.
  * @return void
  */
 public static function onAfterDelete(Main\Entity\Event $event)
 {
     $id = $event->getParameter('id');
     $id = end($id);
     DiscountEntitiesTable::deleteByDiscount($id);
     DiscountModuleTable::deleteByDiscount($id);
     DiscountGroupTable::deleteByDiscount($id);
     if (self::$deleteCoupons !== false) {
         DiscountCouponTable::deleteByDiscount(self::$deleteCoupons);
         self::$deleteCoupons = false;
     }
     unset($id);
 }
예제 #3
0
 public function runOperation()
 {
     global $APPLICATION;
     $this->getDeliveryCodes();
     $found = false;
     $filter = array('>ID' => $this->lastID, '=VERSION' => Sale\Internals\DiscountTable::VERSION_NEW);
     $discountsIterator = Sale\Internals\DiscountTable::getList(array('select' => array('ID', 'MODIFIED_BY', 'TIMESTAMP_X', 'CONDITIONS_LIST', 'ACTIONS_LIST', 'NAME'), 'filter' => $filter, 'order' => array('ID' => 'ASC'), 'limit' => $this->maxOperationCounter));
     while ($discount = $discountsIterator->fetch()) {
         $found = true;
         $error = array();
         $this->convertDelivery($discount['CONDITIONS_LIST']);
         $rawFields = array('ID' => $discount['ID'], 'CONDITIONS' => $discount['CONDITIONS_LIST'], 'ACTIONS' => $discount['ACTIONS_LIST']);
         if (\CSaleDiscount::checkFields('UPDATE', $rawFields)) {
             $fields = array('MODIFIED_BY' => $discount['MODIFIED_BY'], 'TIMESTAMP_X' => $discount['TIMESTAMP_X'], 'UNPACK' => $rawFields['UNPACK'], 'CONDITIONS' => $discount['CONDITIONS_LIST'], 'VERSION' => Sale\Internals\DiscountTable::VERSION_15);
             if (isset($rawFields['EXECUTE_MODULE'])) {
                 $fields['EXECUTE_MODULE'] = $rawFields['EXECUTE_MODULE'];
             }
             $updateResult = Sale\Internals\DiscountTable::update($discount['ID'], $fields);
             if ($updateResult->isSuccess()) {
                 if (isset($rawFields['ENTITIES'])) {
                     Sale\Internals\DiscountEntitiesTable::updateByDiscount($discount['ID'], $rawFields['ENTITIES'], true);
                 }
                 if (isset($rawFields['HANDLERS']['MODULES'])) {
                     Sale\Internals\DiscountModuleTable::updateByDiscount($discount['ID'], $rawFields['HANDLERS']['MODULES'], true);
                 }
             } else {
                 $error = $updateResult->getErrorMessages();
             }
         } else {
             if ($ex = $APPLICATION->GetException()) {
                 $error[] = $ex->GetString();
             } else {
                 $error[] = Loc::getMessage('SALE_DISCOUNT_REINDEX_UPDATE_UNKNOWN_ERROR');
             }
         }
         $this->lastID = $discount['ID'];
         $this->allOperationCounter++;
         if (!empty($error)) {
             $this->errorCounter++;
             $this->errors[] = Loc::getMessage('SALE_DISCOUNT_REINDEX_ORDER_ERROR_REPORT', array('#URL#' => str_replace('#ID#', $discount['ID'], $this->discountEditUrl), '#TITLE#' => trim((string) $discount['NAME']) != '' ? $discount['NAME'] : $discount['ID'], '#ERRORS#' => implode('; ', $error)));
         }
         if ($this->maxExecutionTime > 0 && time() - $this->startOperationTime > $this->maxExecutionTime) {
             break;
         }
     }
     unset($discount, $discountsIterator);
     if (!$found) {
         $this->finishOperation = true;
     }
 }
예제 #4
0
 /**
  * Load from database need modules list for discounts.
  *
  * @return void
  */
 protected function getDiscountModules()
 {
     if (empty($this->discountIds)) {
         return;
     }
     $loadList = $this->discountIds;
     if (!empty($this->cacheDiscountModules)) {
         $loadList = array();
         foreach ($this->discountIds as $discount) {
             if (!isset($this->cacheDiscountModules['sale' . $discount])) {
                 $loadList[] = $discount;
             }
         }
         unset($discount);
     }
     if (empty($loadList)) {
         return;
     }
     $moduleList = Internals\DiscountModuleTable::getByDiscount($loadList);
     if (!empty($moduleList)) {
         foreach ($moduleList as $discount => $discountModule) {
             $this->cacheDiscountModules['sale' . $discount] = $discountModule;
         }
         unset($discount, $discountModule, $moduleList);
     }
     unset($moduleList);
 }