コード例 #1
0
 public function execute()
 {
     $product_id = (int) waRequest::get('id');
     $product = new shopProduct($product_id);
     $type_model = new shopTypeModel();
     $type = $type_model->getById($product['type_id']);
     if ($product['cross_selling'] === null) {
         $product['cross_selling'] = $type['cross_selling'] ? 1 : 0;
     }
     if ($product['upselling'] === null) {
         $product['upselling'] = $type['upselling'];
     }
     // if manually
     if ($product['cross_selling'] == 2 || $product['upselling'] == 2) {
         $related_model = new shopProductRelatedModel();
         $related = $related_model->getAllRelated($product_id);
     } else {
         $related = array();
     }
     if ($type['upselling']) {
         $type_upselling_model = new shopTypeUpsellingModel();
         $data = $type_upselling_model->getByType($type['id']);
         $type['upselling_html'] = shopSettingsRecommendationsAction::getConditionHTML($data);
     }
     if ($type['cross_selling'] && substr($type['cross_selling'], 0, 9) == 'category/') {
         $category_model = new shopCategoryModel();
         $type['category'] = $category_model->getById(substr($type['cross_selling'], 9));
     }
     $this->view->assign(array('type' => $type, 'product' => $product, 'related' => $related));
 }
コード例 #2
0
 protected function saveUpSelling()
 {
     $value = waRequest::post('value');
     $this->type_model->updateById($this->type_id, array('upselling' => $value));
     $type_upselling_model = new shopTypeUpsellingModel();
     $type_upselling_model->deleteByField('type_id', $this->type_id);
     if ($value) {
         $rows = array();
         $data = waRequest::post('data', array());
         foreach ($data as $feature => $row) {
             if (!isset($row['feature'])) {
                 continue;
             }
             $rows[] = array('type_id' => $this->type_id, 'feature' => $feature, 'feature_id' => isset($row['feature_id']) ? $row['feature_id'] : null, 'cond' => $row['cond'], 'value' => isset($row['value']) ? is_array($row['value']) ? implode(',', $row['value']) : $row['value'] : '');
         }
         if ($rows) {
             $type_upselling_model->multipleInsert($rows);
         }
         $this->response['type_id'] = $this->type_id;
         $this->response['data'] = array('price' => array('feature' => 'price'), 'tag' => array('feature' => 'tag'), 'type_id' => array('feature' => 'type_id'));
         $type_features_model = new shopTypeFeaturesModel();
         $rows = $type_features_model->getByType($this->type_id);
         foreach ($rows as $row) {
             $this->response['data'][$row['code']] = array('feature' => $row['code'], 'feature_id' => $row['feature_id']);
         }
         $data = $type_upselling_model->getByType($this->type_id);
         foreach ($data as $row) {
             $this->response['data'][$row['feature']] = array('feature_id' => $row['feature_id'], 'feature' => $row['feature'], 'cond' => $row['cond'], 'value' => $row['value']);
         }
         $this->response['html'] = shopSettingsRecommendationsAction::getConditionHTML($data);
         $this->response['data'] = array_values($this->response['data']);
     }
 }