public function execute()
 {
     $id = $this->get('id', true);
     $set_model = new shopSetModel();
     $set = $set_model->getById($id);
     if (!$set) {
         throw new waAPIException('invalid_param', 'Set not found', 404);
     }
     $this->response = $set;
 }
 public function execute()
 {
     $id = $this->get('id', true);
     $this->getProduct($id);
     $set_id = $this->post('set_id', true);
     $set_model = new shopSetModel();
     $set = $set_model->getById($set_id);
     if (!$set) {
         throw new waAPIException('invalid_param', 'Set not found', 404);
     }
     if ($set['type'] == shopSetModel::TYPE_DYNAMIC) {
         throw new waAPIException('invalid_param', 'Set type must be static');
     }
     $set_products_model = new shopSetProductsModel();
     $this->response = $set_products_model->deleteProducts($set_id, $id);
 }
Esempio n. 3
0
 public function execute()
 {
     $id = $this->get('id', true);
     $set_model = new shopSetModel();
     $set = $set_model->getById($id);
     if (!$set) {
         throw new waAPIException('invalid_param', 'Set not found', 404);
     }
     $data = array();
     foreach (array('id', 'name') as $k) {
         if (waRequest::post($k)) {
             $data[$k] = waRequest::post($k);
         }
     }
     if (!$data) {
         throw new waAPIException('invalid_param', 'Required parameter is missing: id or name', 400);
     }
     $set_model->update($id, $data);
     $method = new shopSetGetInfoMethod();
     $this->response = $method->getResponse(true);
 }
 /**
  * @param int $id - ID of the set
  * @param bool $auto_title
  */
 protected function setPrepare($id, $auto_title = true)
 {
     $set_model = new shopSetModel();
     $set = $set_model->getById($id);
     if (!$set) {
         $this->where[] = '0';
         return;
     }
     $this->info = $set;
     $this->info['hash'] = 'set';
     if ($auto_title) {
         $this->addTitle($set['name']);
     }
     if ($set['type'] == shopSetModel::TYPE_STATIC) {
         $alias = $this->addJoin('shop_set_products', null, ":table.set_id = '" . $set_model->escape($id) . "'");
         if (!waRequest::get('sort') || waRequest::get('sort') == 'sort') {
             $this->order_by = $alias . '.sort ASC';
         }
     } else {
         if (!waRequest::get('sort') && !empty($set['rule'])) {
             $this->order_by = $set['rule'];
         }
     }
 }
 private function getSetSettings($id)
 {
     $set_model = new shopSetModel();
     $settings = $set_model->getById($id);
     /**
      * @event backend_set_dialog
      * @param array $set
      * @return array[string][string] $return[%plugin_id%] html output for dialog
      */
     $this->view->assign('event_dialog', wa()->event('backend_set_dialog', $settings));
     return $settings ? $settings : array();
 }