public function index($id = 0, $color = 0, $design_id = '') { $id = (int) $id; $data = array(); $data['color'] = (string) $color; $data['design_id'] = $design_id; $this->load->model('settings_m'); $setting = $this->settings_m->getSetting(); $data['setting'] = json_decode($setting->settings); $langFile = ROOTPATH . DS . 'media' . DS . 'data' . DS . 'lang.ini'; $data['lang'] = parse_ini_file($langFile); // get product default or product id if ($id > 0) { $fields = array('id' => $id, 'published' => 1); } else { $fields = array('published' => 1); } $this->load->model('product_m'); $rows = $this->product_m->getProduct($fields); if ($rows != false) { $product = $rows[0]; // get product design $design = $this->product_m->getProductDesign($product->id); if ($design == false) { $product = false; } else { $this->load->helper('product'); $help_design = new helperProduct(); $product->design = $help_design->getDesign($design); // attribute $attribute = $this->product_m->getAttribute($product->id); if (count($attribute)) { $product->attribute = $help_design->displayAttributes($attribute); } else { $product->attribute = ''; } $product->attribute = $help_design->quantity($product->min_order) . $product->attribute; $this->load->model('categories_m'); $product->categories = $this->categories_m->getCategories('product'); } $data['product'] = $product; } else { $data['product'] = false; } $data['user'] = $this->session->userdata('user'); // check user admin $is_admin = true; if (empty($data['user']['id'])) { $is_admin = false; } else { //$this->load->model('users_m'); //$is_admin = $this->users_m->userPermission('art'); } $data['is_admin'] = $is_admin; $designer = $this->load->view('components/design/designer', $data, true); $this->data['meta'] = '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=1, minimum-scale=0.5, maximum-scale=1.0"/>'; $this->data['content'] = $designer; $this->data['subview'] = $this->load->view('layouts/design/default', array(), true); $this->theme($this->data, 'design'); }
function getDesign($id = '') { $data = array(); if ($id == '') { $this->msgError(); } $this->load->model('product_m'); // get product info $fields = array('id' => $id, 'published' => 1); $rows = $this->product_m->getProduct($fields); // check product if ($rows == false) { $this->msgError(); } $product = $rows[0]; // product design $design = $this->product_m->getProductDesign($id); if (count($design) == 0) { $this->msgError(); } $this->load->helper('product'); $help_design = new helperProduct(); $product->design = $help_design->getDesign($design); // get product attribute $attribute = $this->product_m->getAttribute($id); if (count($attribute)) { $product->attribute = $help_design->displayAttributes($attribute); } else { $product->attribute = ''; } $product->attribute = $help_design->quantity($product->min_order) . $product->attribute; $data = array(); $data['status'] = 1; $data['product'] = $product; echo json_encode($data); exit; }
public function index($string = '', $color = '') { $id = (int) $string; // page not found $found = true; if ($id == 0) { $found = false; } else { // load product info $this->load->model('product_m'); $row = $this->product_m->getProduct(array('id' => $id, 'published' => 1)); if (empty($row[0]) || count($row[0]) == 0) { $found = false; } } $data = array(); if ($found === false) { // load 404 $data['subview'] = $this->load->view('layouts/404/404', array(), true); } else { $this->data = array(); $product = $row[0]; // get attributes $attribute = $this->product_m->getAttribute($id); if (count($attribute)) { $this->load->helper('product'); $help_product = new helperProduct(); $product->attributes = $help_product->displayAttributes($attribute); } // get product design $design = $this->product_m->getProductDesign($id); if (count($design)) { $product->design = $help_product->getDesign($design); } // product color $this->data['color_load'] = false; $this->data['index'] = ''; if ($color != '') { $index = (int) $color; if (isset($product->design->color_hex[$index])) { $this->data['index'] = $index; $this->data['color_load'] = true; $this->data['color_active'] = str_replace($index . '-', '', $color); } } $this->data['product_m'] = $this->product_m; $this->data['product'] = $product; // load Related $product_cate = $this->product_m->getProductCate($id); $cate_id = array(); foreach ($product_cate as $cate) { $cate_id[] = $cate->cate_id; } $this->data['products'] = $this->product_m->getRelated($cate_id, $id); // load view data $content = $this->load->view('components/product/default', $this->data, true); $data['content'] = $content; // load layout of each product $this->load->model('layout_m'); $layout = $this->layout_m->getProductPage($id); if ($layout == '') { $layout = $this->load->view('layouts/product/default', array(), true); } $data['subview'] = $layout; // load Meta if ($product->meta_title != '') { $data['title'] = $product->meta_title; } if ($product->meta_keywords != '') { $data['meta_keywords'] = $product->meta_keywords; } if ($product->meta_description != '') { $data['meta_description'] = $product->meta_description; } } $this->theme($data, 'product'); }