Exemplo n.º 1
0
 /**
  * 更新商品中的默认规格商品价格
  */
 public function update_product_default_attribute_price()
 {
     $site = Mysite::instance($this->site_id)->get();
     if ($_POST) {
         $domain = $this->input->post('domain');
         if (empty($domain) || $domain != $site['domain']) {
             remind::set(Kohana::lang('o_global.input_error'), 'site/update/update_product_seo');
         }
         $query_struct = array('where' => array('site_id' => $this->site_id), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0));
         $product_count = Myproduct::instance()->count($query_struct);
         //1000个商品以下直接读取所有的商品
         if ($product_count < 1000) {
             $query_struct['limit']['per_page'] = $product_count;
             $products = Myproduct::instance()->lists($query_struct);
             $product_skus = array();
             foreach ($products as $key => $value) {
                 $query_struct = array('where' => array('site_id' => $this->site_id, 'product_id' => $value['id'], 'default_on' => 1), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0));
                 $default_product_attributes = Myproduct_attribute::instance()->lists($query_struct);
                 $data = array();
                 if (count($default_product_attributes) > 0) {
                     $default_product_attribute = array_shift($default_product_attributes);
                     if (isset($default_product_attribute['price']) && $default_product_attribute['price'] > 0) {
                         $data['default_attr_price'] = $value['price'] + $default_product_attribute['price'];
                     } else {
                         $data['default_attr_price'] = $value['price'];
                     }
                 } else {
                     $data['default_attr_price'] = $value['price'];
                 }
                 if (!Myproduct::instance($value['id'])->edit($data)) {
                     $product_skus[] = $value['SKU'];
                 }
             }
         } else {
             remind::set(Kohana::lang('o_site.product_request_check'), 'site/update/update_product_name_url');
         }
         if (count($product_skus) > 0) {
             $product_sku_str = '';
             foreach ($product_skus as $key => $value) {
                 $product_sku_str = $value . '|';
             }
             remind::set(Kohana::lang('o_site.sku_update_error') . $product_sku_str, 'site/update/update_product_name_url');
         } else {
             remind::set(Kohana::lang('o_site.sku_update_success'), 'site/update/update_product_name_url', 'success');
         }
     }
     $this->template->content = new View("site/update_product_default_attribute_price");
     $this->template->content->site = $site;
 }
Exemplo n.º 2
0
 public function update_seo_manage_by_site_id($site_id)
 {
     $seo_manages = self::get_seo_manage_by_site_id($site_id);
     foreach ($seo_manages as $key => $seo_manage) {
         $request_struct = array('where' => array('site_id' => $site_id, 'id' => $key), 'like' => array(), 'orderby' => array('update_timestamp' => 'ASC'), 'limit' => array());
         $result = $this->lists($request_struct);
         foreach ($result as $result) {
             $request_data = array('date_upd' => $result['update_timestamp'], 'meta_title' => $result['meta_title'], 'meta_keywords' => $result['meta_keywords'], 'meta_description' => $result['meta_description']);
         }
         foreach ($seo_manage['id'] as $id) {
             $query_struct['where']['category_id'] = $id;
             $category_products = Mycategory_product::instance()->lists($query_struct);
             foreach ($category_products as $key => $value) {
                 $products[] = Myproduct::instance($value['product_id'])->get();
             }
             foreach ($products as $key => $val) {
                 Myproduct::instance($val['id'])->edit($request_data);
             }
         }
     }
 }
Exemplo n.º 3
0
 public function search_product()
 {
     role::check('promotion_coupon');
     // 收集请求数据
     $request_data = $this->input->get();
     $request_struct_current = array('where' => array(), 'like' => array(), 'orderby' => array('name' => 'ASC'));
     // 当前支持的查询业务逻辑
     if (isset($request_data['type']) && isset($request_data['keyword']) && !empty($request_data['keyword'])) {
         switch ($request_data['type']) {
             case 'id':
                 $request_struct_current['where'][$request_data['type']] = intval(trim($request_data['keyword']));
                 break;
             case 'name_url':
                 $request_struct_current['where'][$request_data['type']] = trim($request_data['keyword']);
                 break;
             case 'name':
                 $request_struct_current['like'][$request_data['type']] = trim($request_data['keyword']);
                 break;
             case 'SKU':
                 $request_struct_current['where'][$request_data['type']] = trim($request_data['keyword']);
                 break;
         }
     }
     $products = Myproduct::instance()->lists($request_struct_current);
     //header('Content-Type: text/javascript; charset=UTF-8');
     echo json_encode($products);
     exit;
 }
Exemplo n.º 4
0
 /**
  * 分类编辑显示
  */
 public function add_product()
 {
     $id = $this->input->get('id');
     $category = Mycategory::instance($id)->get();
     if (!$category['id']) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $site_id_list = role::check('product_virtual_category', 0, 0);
     // 权限验证
     if (!in_array($category['site_id'], $site_id_list)) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $this->template->content = new View("product/virtualcategory_product_add");
     $this->template->content->data = $category;
     $this->template->content->site = Mysite::instance($category['site_id'])->get();
     $this->template->content->product_list = Myproduct::instance()->site_product_select_list($category['site_id']);
 }