Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/indolok.id/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Product extends Public_Controller { public function __construct() { parent::__construct(); } public function get($alias = NULL) { if ($alias == NULL) { show_404(); } //check if product exist $this->db->select('*')->from('products')->where('alias', $alias)->where('product_status', 1); $count = $this->db->get()->num_rows(); if ($count == 0) { show_404(); } //set url to session, so can be access by cart page, continue shopping link button $this->session->set_userdata('from_product_page', base_url() . 'product/' . $alias); //get this product data $this->db->select('*')->from('products')->where('alias', $alias); $data['product'] = $this->db->get()->row(); //get this product details $product_id = (int) $data['product']->id_products; //get product code (SKU), weight, and stock display status $this->db->select('show_product_sku, show_product_weight, show_product_stock')->from('configuration')->where('id_configuration', 1); $display_status = $this->db->get()->row(); $data['display_sku'] = $display_status->show_product_sku; $data['display_weight'] = $display_status->show_product_weight; $data['display_stock'] = $display_status->show_product_stock; $this->load->helper('product'); $category_discount_percentage = category_discount($product_id); //check if point rewards program is active or not. $this->db->select('*')->from('point_rewards')->where('id_point_rewards', 1); $data['point_rewards'] = $this->db->get()->row(); //get brand name $this->db->select('brand')->from('brands')->where('id_brands', $data['product']->brand_id); $data['brand_name'] = $this->db->get()->row()->brand; //LOAD LANGUAGE FILES if($this->session->userdata('site_lang') == 'english') { $this->lang->load('product_detail', 'english'); $this->lang->load('product_list', 'english'); } else { $this->lang->load('product_detail', 'indonesian'); $this->lang->load('product_list', 'indonesian'); } //check for flash sale if($this->session->has_userdata('flashsale_id_active')) { //if flashdata session is currently active $this->db->select('product_id, discounted_price')->from('flashsale_products')->where('flashsale_id',$this->session->userdata('flashsale_id_active'))->where('product_id',$product_id); $data['flashsale_product'] = $this->db->get()->row(); } //get product reviews $this->db->select('*')->from('product_review')->where('product_id', $product_id); $data['product_reviews'] = $this->db->get()->result(); //get SEO $this->data_header['browser_title'] = 'Product - ' . ucwords($data['product']->title); $this->data_header['meta_description'] = $data['product']->meta_description; //get warehouse with available stock $data['warehouses'] = $this->db->select('warehouse_id, stock, name')->from('stock')->join('warehouse', 'warehouse.id = stock.warehouse_id')->where('id_product', $product_id)->get()->result(); //add product view into log $log_data = array( 'product_id' => $product_id, 'ip' => $this->input->ip_address(), 'created_at' => date('Y-m-d H:i:s') ); $this->db->insert('product_view', $log_data); //get count $this->db->distinct(); $this->db->select('ip'); $this->db->from('product_view'); $this->db->where('product_id', $product_id); $data['count_view'] = count($this->db->get()->result_array()); $this->load->view("themes/$this->theme_no/header", $this->data_header); $this->load->view("themes/$this->theme_no/product", $data); $this->load->view("themes/$this->theme_no/footer", $this->data_footer); } }