|
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/angkasapuraretail.com/public_html/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('id_products')->from('products')->where('alias', $alias)->where('product_status', 1);
$count = $this->db->get()->num_rows();
if ($count == 0) { redirect(base_url('shop')); }
//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_array();
//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');
}
//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());
//get category and products by category
$category_id = $this->db->select('id_category')->from('category_product')->where('id_product', $product_id)->get()->row()->id_category;
//get all products by category, except current product
$data['similar_products'] = $this->db->select('title, alias, image1, is_sale, sale_price, discounted_price, new_arrival')->from('products')->join('category_product', 'products.id_products = category_product.id_product')->where('product_status', '1')->where('id_products !=', $product_id)->where('id_category', $category_id)->limit(4)->order_by('id_products', 'RANDOM')->get()->result();
$this->data_header['categories'] = $this->db->select('category, alias')->from('categories')->where('status', '1')->order_by('priority', 'ASC')->get()->result();
$this->load->view("themes/$this->theme_no/header-shop", $this->data_header);
$this->load->view("themes/$this->theme_no/product", $data);
$this->load->view("themes/$this->theme_no/footer-shop", $this->data_footer);
}
}