Пример #1
0
 /**
  * main action
  */
 public function mainAction()
 {
     /**
      * input data
      */
     $offer_group_id = (int) $this->GET['offer_group_id'];
     $campaign_category_id = (int) $this->GET['campaign_category_id'];
     $roundel_category_id = (int) $this->GET['roundel_category_id'];
     $template = (string) $this->GET['template'];
     $includeForthcoming = $_SESSION['fe_edit_mode'] == 'edit';
     if ($this->GET['taxonomy_tree_id']) {
         $taxonomy_tree_ids = explode(",", $this->GET['taxonomy_tree_id']);
         if (count($taxonomy_tree_ids) == 0) {
             $taxonomy_tree_ids = array();
         }
     }
     /**
      * initialise and get product list
      */
     $Offer = new ecommerce_offer();
     $product_ids = $Offer->getProductIdsForOfferGroup($offer_group_id, $campaign_category_id, $roundel_category_id, $taxonomy_tree_ids, $includeForthcoming);
     if (count($product_ids) > 0) {
         /**
          * build HTTP query
          */
         $list = array();
         foreach ($product_ids as $id) {
             $list['product_id_list'][] = $id;
         }
         if (isset($this->GET['limit_from'])) {
             $list['limit_from'] = $this->GET['limit_from'];
         }
         if (isset($this->GET['limit_per_page'])) {
             $list['limit_per_page'] = $this->GET['limit_per_page'];
         }
         if (isset($this->GET['display_pagination'])) {
             $list['display_pagination'] = $this->GET['display_pagination'];
         }
         if (!isset($this->GET['sort']['by'])) {
             $list['product_id_list_force_sorting_as_listed'] = 1;
         } else {
             if (isset($this->GET['sort']['by'])) {
                 $list['sort']['by'] = $this->GET['sort']['by'];
             }
             if (isset($this->GET['sort']['direction'])) {
                 $list['sort']['direction'] = $this->GET['sort']['direction'];
             }
         }
         $query = http_build_query($list, '', ':');
         /**
          * call product_list component
          */
         $_Onxshop_Request = new Onxshop_Request("component/ecommerce/product_list_{$template}~{$query}~");
         $this->tpl->assign('PRODUCT_LIST', $_Onxshop_Request->getContent());
     }
     return true;
 }
Пример #2
0
 /**
  * getOffersList
  */
 public function getOffersList()
 {
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_offer.php';
     $Offer = new ecommerce_offer();
     /**
      * get special offer list
      */
     $records = $Offer->getActiveOffers();
     return $records;
 }
Пример #3
0
 /**
  * main action
  */
 public function mainAction()
 {
     $Offer = new ecommerce_offer();
     $includeForthcoming = $_SESSION['fe_edit_mode'] == 'edit';
     $offers = $Offer->getActiveOffers($includeForthcoming);
     foreach ($offers as $offer) {
         $offer['price_formatted'] = $this->formatPrice($offer['price'], $offer['currency_code']);
         $offer['title'] = $this->getRoundelText($offer);
         $offer['image'] = $this->getRoundelImageSource($offer);
         $this->tpl->assign("ITEM", $offer);
         $this->tpl->parse("content.item");
     }
     return true;
 }
Пример #4
0
 protected function initModels()
 {
     $this->Offer = new ecommerce_offer();
     $this->Offer_Group = new ecommerce_offer_group();
     $this->Taxonomy = new common_taxonomy();
     $this->Price = new ecommerce_price();
     $this->conf = ecommerce_offer::initConfiguration();
 }
Пример #5
0
 /**
  * get data
  */
 public function getData()
 {
     $data = '';
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_offer.php';
     $Offer = new ecommerce_offer();
     /**
      * get special offer list
      */
     $records = $Offer->getActiveOffers();
     $data = array();
     foreach ($records as $record) {
         $item = $this->formatItem($record);
         $data[] = $item;
     }
     return $data;
 }
Пример #6
0
 /**
  * get data
  */
 public function getData()
 {
     $data = '';
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_offer.php';
     $Offer = new ecommerce_offer();
     /**
      * get special offer list
      */
     $records = $Offer->getActiveOffers();
     $data = array();
     foreach ($records as $record) {
         $item = $this->formatItem($record);
         //API 1.0 is showing expiry date without time and as day when the offer is taken down
         $item['expiry_date'] = date('Y-m-d', strtotime($item['expiry_date']) + 86400);
         $data[] = $item;
     }
     return $data;
 }
Пример #7
0
 /**
  * post action
  */
 function post()
 {
     parent::post();
     //dropdowns
     $Offer_Group = new ecommerce_offer_group();
     $Taxonomy = new common_taxonomy();
     $conf = ecommerce_offer::initConfiguration();
     $groups_in_progress = $Offer_Group->listing("schedule_start <= NOW() AND (schedule_end IS NULL OR schedule_end >= NOW())", "id DESC");
     $groups_scheduled = $Offer_Group->listing("schedule_start > NOW()", "id DESC");
     $groups_past = $Offer_Group->listing("(schedule_start < NOW() OR schedule_start IS NULL) AND schedule_end IS NOT NULL AND schedule_end < NOW()", "id DESC");
     $campaign_categories = $Taxonomy->getChildren($conf['campaign_category_parent_id']);
     $roundel_categories = $Taxonomy->getChildren($conf['roundel_category_parent_id']);
     $this->parseOffersSelectGroup($groups_in_progress, 'In Progress', $this->node_data['component']['offer_group_id']);
     $this->parseOffersSelectGroup($groups_scheduled, 'Scheduled', $this->node_data['component']['offer_group_id']);
     $this->parseOffersSelectGroup($groups_past, 'Past', $this->node_data['component']['offer_group_id']);
     $this->parseCategorySelect($campaign_categories, $this->node_data['component']['campaign_category_id'], 'campaign_category_item');
     $this->parseCategorySelect($roundel_categories, $this->node_data['component']['roundel_category_id'], 'roundel_category_item');
     $this->parseTemplatesSelect($this->node_data['component']['template']);
 }