function index()
 {
     $cart =& $this->locator->get('cart');
     $currency =& $this->locator->get('currency');
     $customer =& $this->locator->get('customer');
     $language =& $this->locator->get('language');
     $image =& $this->locator->get('image');
     $request =& $this->locator->get('request');
     $response =& $this->locator->get('response');
     $session =& $this->locator->get('session');
     $tax =& $this->locator->get('tax');
     $url =& $this->locator->get('url');
     $head_def =& $this->locator->get('HeaderDefinition');
     require_once 'library/application/string_modify.php';
     //pagination
     $session->set('search.page', $request->has('page') && $request->gethtml('page') > 0 ? abs((int) $request->gethtml('page')) : 1);
     $language->load('controller/search.php');
     $this->template->set('title', $language->get('heading_title'));
     $view = $this->locator->create('template');
     $view->set('heading_title', $language->get('heading_title'));
     $view->set('tax_included', $this->config->get('config_tax'));
     $view->set('text_critea', $language->get('text_critea'));
     $view->set('text_search', $language->get('text_search'));
     $view->set('text_keywords', $language->get('text_keywords'));
     $view->set('text_error', $language->get('text_error'));
     $view->set('entry_search', $language->get('entry_search'));
     $view->set('entry_description', $language->get('entry_description'));
     $view->set('entry_page', $language->get('entry_page'));
     $view->set('button_search', $language->get('button_search'));
     $view->set('action', $url->href('search', 'search_page'));
     $view->set('location', 'content');
     // Set Session Variables for options
     if ($session->get('search.columns')) {
         $columns = $session->get('search.columns');
     } else {
         $columns = $this->config->get('search_columns');
         $session->set('search.columns', $columns);
     }
     if ($session->get('search.page_rows')) {
         $page_rows = (int) $session->get('search.page_rows');
     } else {
         $page_rows = $this->config->get('search_rows') ? $this->config->get('search_rows') : $this->config->get('config_max_rows');
     }
     if ($columns > 1) {
         $page_rows = ceil($page_rows / $columns) * $columns;
     }
     $session->set('search.page_rows', $page_rows);
     if ($session->has('search.max_rows') && $session->get('search.max_rows') >= 0) {
         $max_rows = (int) $session->get('search.max_rows');
         if ($max_rows < $page_rows && $max_rows > 0) {
             $max_rows = $page_rows;
         } else {
             if ($max_rows < 0) {
                 $max_rows = 0;
             }
         }
     } else {
         $max_rows = $this->config->get('search_limit');
     }
     $session->set('search.max_rows', $max_rows);
     if ($session->get('search.sort_order')) {
         $default_order = $session->get('search.sort_order');
     } else {
         $default_order = $language->get('entry_ascending');
         $session->set('search.sort_order', $default_order);
     }
     if ($session->get('search.sort_filter')) {
         $default_filter = $session->get('search.sort_filter');
     } else {
         $default_filter = $language->get('entry_number');
         $session->set('search.sort_filter', $default_filter);
     }
     if ($default_filter == $language->get('entry_number')) {
         $search_filter = ' order by p.sort_order, pd.name ';
     } else {
         $search_filter = ' order by p.price ';
     }
     if ($default_order == $language->get('entry_ascending')) {
         $search_order = ' asc ';
     } else {
         $search_order = ' desc ';
     }
     // Manufacturer Session
     $man_search = explode('*_*', $session->get('search.manufacturer'));
     if (end($man_search) == $session->get('search.search')) {
         $manufacturer_id = (int) substr($session->get('search.manufacturer'), 0, strpos($session->get('search.manufacturer'), "*_*"));
         if ($manufacturer_id > 0) {
             $manufacturer_filter = "'" . $manufacturer_id . "'";
             $manufacturer_sql = " and p.manufacturer_id = ";
         } else {
             $manufacturer_filter = "";
             $manufacturer_sql = "";
             $session->set('search.manufacturer', 0 . "*_*" . $session->get('search.search'));
         }
     } else {
         $manufacturer_filter = "";
         $manufacturer_sql = "";
         $session->set('search.manufacturer', 0 . "*_*" . $session->get('search.search'));
     }
     // Model Session
     $model_search = explode('*_*', $session->get('search.model'));
     if (end($model_search) == $session->get('search.search')) {
         $model = substr($session->get('search.model'), 0, strpos($session->get('search.model'), "*_*"));
         if ($model && $model != "all") {
             $model_sql = " and pd.model like ";
             $model_filter = "'" . $model . "'";
         } else {
             $model_sql = "";
             $model_filter = "";
             $session->set('search.model', 'all' . "*_*" . $session->get('search.search'));
         }
     } else {
         $model_sql = "";
         $model_filter = "";
         $session->set('search.model', 'all' . "*_*" . $session->get('search.search'));
     }
     $view->set('model', substr($session->get('search.model'), 0, strpos($session->get('search.model'), "*_*")));
     $view->set('manufacturer', $session->get('search.manufacturer'));
     // End Set Session Variables for options
     // Image size
     if ($columns == 1) {
         $image_width = $this->config->get('search_image_width');
         $image_height = $this->config->get('search_image_height');
     } else {
         if ($columns <= 3) {
             $image_width = $this->config->get('search_image_width') <= 175 ? $this->config->get('search_image_width') : 175;
             $image_height = $this->config->get('search_image_height') <= 175 ? $this->config->get('search_image_height') : 175;
         } else {
             $image_width = $this->config->get('search_image_width') <= 140 ? $this->config->get('search_image_width') : 140;
             $image_height = $this->config->get('search_image_height') <= 140 ? $this->config->get('search_image_height') : 140;
         }
     }
     // End image
     $view->set('max_rows', $max_rows);
     $view->set('columns', $columns);
     $view->set('page_rows', $page_rows);
     $view->set('default_order', $default_order);
     $view->set('default_filter', $default_filter);
     $view->set('display_lock', $this->config->get('search_display_lock'));
     $view->set('options_manufacturer', $this->config->get('options_manufacturer'));
     $view->set('options_model', $this->config->get('options_model'));
     $view->set('default_max_rows', (int) $session->get('search.max_rows'));
     $view->set('default_page_rows', (int) $session->get('search.page_rows'));
     $manufacturer_id = (int) substr($session->get('search.manufacturer'), 0, strpos($session->get('search.manufacturer'), "*_*"));
     //new
     $search = wildcardsearch($session->get('search.search'), $language);
     $view->set('search', $search);
     $description = $session->get('search.description');
     $view->set('description', $description);
     if ($description == "on") {
         $description_sql = "or pd.description like ";
         $search_description = $search;
     } else {
         $description_sql = '';
         $search_description = '';
     }
     $man_results = $this->modelSearch->get_manufacturer($search, $description_sql, $search_description);
     if (count($man_results) > 1) {
         $manufacturers_data = array();
         foreach ($man_results as $man_result) {
             $result = $this->modelProducts->getRow_manufacturer($man_result['manufacturer_id']);
             $manufacturers_data[] = array('manufacturer' => $result['manufacturer_id'] . "*_*" . $session->get('search.search'), 'name' => $result['name']);
         }
     } else {
         $manufacturers_data = "";
     }
     if ($manufacturer_id > 0) {
         $manufacturer_sql = " and p.manufacturer_id = ";
         $manufacturer_filter = "'" . $manufacturer_id . "'";
     } else {
         $manufacturer_sql = "";
         $manufacturer_filter = "";
     }
     $results = $this->modelSearch->get_model($search, $description_sql, $search_description, $manufacturer_sql, $manufacturer_filter);
     if (count($results) > 1) {
         $model_data = array();
         foreach ($results as $result) {
             $model_data[] = array('model' => $result['model'], 'model_value' => $result['model'] . "*_*" . $session->get('search.search'));
         }
     } else {
         $model_data = "";
     }
     $view->set('models_data', $model_data);
     if ($session->get('search.search')) {
         $results = $this->modelSearch->get_products($search, $description_sql, $search_description, $manufacturer_sql, $manufacturer_filter, $model_sql, $model_filter, $search_filter, $search_order, $page_rows, $max_rows);
         $view->set('discount_options', $this->config->get('config_discount_options'));
         //****
         // Currency
         $currency_code = $currency->code;
         $symbol_right = $currency->currencies[$currency_code]['symbol_right'];
         $symbol_left = $currency->currencies[$currency_code]['symbol_left'];
         $view->set('symbols', array($symbol_left, $symbol_right, $language->get('thousand_point')));
         $view->set('price_with_options', $language->get('price_with_options'));
         $view->set('symbol_right', $symbol_right);
         $view->set('symbol_left', $symbol_left);
         $view->set('decimal_point', $language->get('decimal_point'));
         $view->set('thousand_point', $language->get('thousand_point'));
         $view->set('decimal_place', $currency->currencies[$currency_code]['decimal_place']);
         // End Currency
         if ($results) {
             $view->set('text_results', $this->modelSearch->get_text_results());
             $product_data = array();
             foreach ($results as $result) {
                 if ($this->config->get('search_ratings')) {
                     $averageRating = number_format($this->modelProducts->getAverageRating($result['product_id']), 0);
                     $alt_rating = $language->get('text_out_of', $averageRating);
                 } else {
                     $averageRating = NULL;
                     $alt_rating = NULL;
                 }
                 $days_remaining = '';
                 //***
                 if ($result['special_price'] > 0 && date('Y-m-d') >= $result['sale_start_date'] && date('Y-m-d') <= $result['sale_end_date']) {
                     $this->discounted = true;
                     // we have at least 1 price_old div
                     if ($this->discounted && $result['remaining']) {
                         $this->remaining = true;
                         // we have at least 1 remaining div
                     }
                     $number_days = intval((strtotime($result['sale_end_date']) - time()) / 86400);
                     $days_remaining = $language->get($number_days > 1 ? 'days_remaining' : 'day_remaining', $number_days ? $number_days : 1);
                 }
                 if ($result['vendor_id'] != '0' && $this->config->get('config_unregistered')) {
                     $vendor = $this->modelProducts->get_vendor($result['vendor_id']);
                     $vendor_name = $vendor['name'];
                 } else {
                     $vendor_name = NULL;
                 }
                 // Product Discounts
                 $discounts = $this->modelProducts->get_product_discount($result['product_id']);
                 $product_discounts = array();
                 if ($discounts) {
                     foreach ($discounts as $discount) {
                         if ($result['special_price'] > 0 && date('Y-m-d') >= $result['sale_start_date'] && date('Y-m-d') <= $result['sale_end_date']) {
                             $discount_amount = $result['special_price'] * ($discount['discount'] / 100);
                         } else {
                             $discount_amount = $result['price'] * ($discount['discount'] / 100);
                         }
                         $product_discounts[] = array('discount_quantity' => $discount['quantity'], 'discount_percent' => round($discount['discount'] * 10) / 10, 'discount_amount' => number_format($tax->calculate($discount_amount, $result['tax_class_id'], $this->config->get('config_tax')), $currency->currencies[$currency_code]['decimal_place'], $language->get('decimal_point'), ''));
                     }
                 }
                 // End product Discounts
                 // Product Options
                 if ($columns == 1) {
                     $options = $this->modelProducts->get_options($result['product_id'], $result['tax_class_id']);
                     $product_options = $this->modelProducts->get_product_with_options($result['product_id'], $image_width, $image_height);
                 } else {
                     $options = $this->modelProducts->get_option_names($result['product_id']);
                     $product_options = FALSE;
                 }
                 // End Product Options
                 // Description
                 if ($columns == 1) {
                     $lines = $this->config->get('content_lines_single') ? $this->config->get('content_lines_single') : 6;
                     $desc = formatedstring($result['description'], $lines);
                 } else {
                     if ($columns <= 3) {
                         $lines = $this->config->get('content_lines_multi') ? $this->config->get('content_lines_multi') : $lines;
                         if ($result['alt_description']) {
                             $desc = formatedstring($result['alt_description'], $lines);
                         } else {
                             $desc = formatedstring($result['description'], 4);
                         }
                     } else {
                         $lines = $this->config->get('content_lines_char') ? $this->config->get('content_lines_char') : 108;
                         if ($result['alt_description']) {
                             $desc = strippedstring($result['alt_description'], $lines);
                         } else {
                             $desc = strippedstring($result['description'], $lines);
                         }
                     }
                 }
                 // End Description
                 $product_data[] = array('name' => $result['name'], 'product_id' => $result['product_id'], 'description' => $desc, 'stock_level' => $result['quantity'], 'min_qty' => $result['min_qty'], 'max_qty' => $result['max_qty'], 'multiple' => $result['multiple'], 'cart_level' => $cart->hasProduct($result['product_id']), 'product_discounts' => $product_discounts, 'href' => $url->href('product', FALSE, array('product_id' => $result['product_id'])), 'popup' => $image->href($result['filename']), 'thumb' => $image->resize($result['filename'], $image_width, $image_height), 'special_price' => $currency->format($tax->calculate($result['special_price'], $result['tax_class_id'], $this->config->get('config_tax'))), 'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))), 'sale_start_date' => $result['sale_start_date'], 'sale_end_date' => $result['sale_end_date'], 'show_days_remaining' => $result['remaining'], 'options' => $options, 'model_number' => $result['model_number'], 'product_options' => $product_options, 'days_remaining' => $days_remaining, 'average_rating' => $averageRating, 'alt_rating' => $alt_rating, 'vendor_name' => $vendor_name);
             }
             if ($max_rows == $this->modelSearch->get_total()) {
                 $maximum_results = 1;
             } else {
                 $maximum_results = 0;
             }
             $view->set('maximum_results', $maximum_results);
             $view->set('products', $product_data);
             $view->set('page', $session->get('search.page'));
             $view->set('onhand', $language->get('onhand'));
             $view->set('text_model_number', $language->get('text_model_number'));
             $view->set('manufacturers_data', $manufacturers_data);
             $view->set('manufacturer_id', $session->get('search.manufacturer'));
             $view->set('sort_filter', $this->sort_filter());
             $view->set('sort_order', $this->sort_order());
             $view->set('text_sort_by', $language->get('text_sort_by'));
             $view->set('text_order', $language->get('text_order'));
             $view->set('text_max_rows', $language->get('text_max_rows'));
             $view->set('text_page_rows', $language->get('text_page_rows'));
             $view->set('text_columns', $language->get('text_columns'));
             $view->set('text_manufacturer_all', $language->get('text_manufacturer_all'));
             $view->set('text_manufacturer', $language->get('text_manufacturer'));
             $view->set('text_model', $language->get('text_model'));
             $view->set('text_all', $language->get('text_all'));
             $view->set('entry_submit', $language->get('entry_submit'));
             $view->set('search', $session->get('search.search'));
             //new
             $view->set('text_soldby', $language->get('text_soldby'));
             $view->set('previous', $language->get('previous_page'));
             $view->set('next', $language->get('next_page'));
             $view->set('first_page', $language->get('first_page'));
             $view->set('last_page', $language->get('last_page'));
             $view->set('number_columns', $this->config->get('config_columns') != 3 ? array(1, 2, 3, 4, 5) : array(1, 2, 3, 4));
             $view->set('pages', $this->modelSearch->get_pagination());
             $view->set('total_pages', $this->modelSearch->get_pages());
             $view->set('addtocart_quantity_box', $this->config->get('addtocart_quantity_box'));
             $view->set('addtocart_quantity_max', $this->config->get('addtocart_quantity_max'));
             $view->set('product_options_select', $this->config->get('search_options_select'));
             $view->set('text_options', $language->get('text_options'));
             $view->set('text_quantity_discount', $language->get('text_quantity_discount'));
             $view->set('Add_to_Cart', $language->get('button_add_to_cart'));
             $view->set('Added_to_Cart', $language->get('button_added_to_cart'));
             $view->set('regular_price', $language->get('regular_price'));
             $view->set('sale_price', $language->get('sale_price'));
         }
     }
     $view->set('show_stock', $this->config->get('config_show_stock'));
     $view->set('show_stock_icon', $this->config->get('config_show_stock_icon'));
     if ($this->config->get('config_show_stock_icon')) {
         $view->set('low_stock_warning', $this->config->get('config_low_stock_warning'));
     }
     $view->set('text_stock_icon', $language->get('text_stock_icon'));
     $view->set('addtocart', $this->config->get('search_addtocart'));
     $view->set('text_inc_results', $language->get('text_inc_results'));
     $view->set('text_max_reached', $language->get('text_max_reached'));
     $view->set('entry_max_results', $language->get('entry_max_results'));
     $view->set('head_def', $head_def);
     $this->template->set('head_def', $head_def);
     $view->set('remaining', $this->remaining);
     $view->set('discounted', $this->discounted);
     $view->set('text_enlarge', $language->get('text_enlarge'));
     $view->set('image_display', $this->config->get('content_image_display'));
     $view->set('this_controller', 'search');
     $view->set('tpl_columns', $this->modelCore->tpl_columns);
     $this->template->set('content', $view->fetch('content/search.tpl'));
     $this->load_modules();
     // Template Manager
     $this->set_tpl_modules();
     // Template Manager
     $this->template->set($this->module->fetch());
     $response->set($this->template->fetch('layout.tpl'));
 }
 function fetch()
 {
     $cart =& $this->locator->get('cart');
     $config =& $this->locator->get('config');
     $currency =& $this->locator->get('currency');
     $database =& $this->locator->get('database');
     $language =& $this->locator->get('language');
     $image =& $this->locator->get('image');
     $tax =& $this->locator->get('tax');
     $url =& $this->locator->get('url');
     $request =& $this->locator->get('request');
     $template =& $this->locator->get('template');
     $rand =& $this->locator->get('randomnumber');
     $head_def =& $this->locator->get('HeaderDefinition');
     $this->modelProducts = $this->model->get('model_products');
     $this->modelCore = $this->model->get('model_core');
     require_once 'library/application/string_modify.php';
     if ($config->get('manufacturerlist_status')) {
         $view = $this->locator->create('template');
         $view->set('onhand', $language->get('onhand'));
         $view->set('tax_included', $config->get('config_tax'));
         if ($config->get('manufacturerlist_total') == '0') {
             $manufacturerlist_total = '';
         } else {
             $manufacturerlist_total = ' limit ' . (int) $config->get('manufacturerlist_total');
         }
         if ($config->get('manufacturerlist_slider')) {
             $limit = $config->get('manufacturerlist_slimit') == '0' ? '' : (int) $config->get('manufacturerlist_slimit');
             $columns = $config->get('manufacturerlist_scolumns');
         } else {
             $limit = $config->get('manufacturerlist_limit') == '0' ? '' : (int) $config->get('manufacturerlist_limit');
             $columns = $config->get('manufacturerlist_columns');
         }
         $controller = $this->modelCore->controller;
         // Template Manager
         $location = $this->modelCore->module_location['manufacturerlist'];
         // Template Manager
         if ($columns == 3) {
             $image_width = $config->get('manufacturerlist_image_width') <= 175 ? $config->get('manufacturerlist_image_width') : 175;
             $image_height = $config->get('manufacturerlist_image_height') <= 175 ? $config->get('manufacturerlist_image_height') : 175;
         } else {
             $image_width = $config->get('manufacturerlist_image_width') <= 140 ? $config->get('manufacturerlist_image_width') : 140;
             $image_height = $config->get('manufacturerlist_image_height') <= 140 ? $config->get('manufacturerlist_image_height') : 140;
         }
         // Currency
         $currency_code = $currency->code;
         $symbol_right = $currency->currencies[$currency_code]['symbol_right'];
         $symbol_left = $currency->currencies[$currency_code]['symbol_left'];
         $view->set('symbols', array($symbol_left, $symbol_right, $language->get('thousand_point')));
         $view->set('symbol_right', $symbol_right);
         $view->set('symbol_left', $symbol_left);
         $view->set('decimal_point', $language->get('decimal_point'));
         $view->set('thousand_point', $language->get('thousand_point'));
         $view->set('decimal_place', $currency->currencies[$currency_code]['decimal_place']);
         // End Currency
         $manufacturers = $database->cache('manufacturer', "select * from manufacturer order by sort_order, name asc");
         $manufacturers_data = array();
         foreach ($manufacturers as $manufacturer) {
             $manufacturers_results = $this->modelProducts->get_manufacturerlist($manufacturer['manufacturer_id'], $manufacturerlist_total);
             $maxrow = count($manufacturers_results) - 1;
             if ($manufacturers_results) {
                 if ($maxrow < $limit) {
                     $results = $manufacturers_results;
                 } else {
                     $i = 0;
                     while ($i < $limit) {
                         $rand->uRand(0, $maxrow);
                         $i++;
                     }
                     $i = 0;
                     $product_rand = array();
                     foreach ($rand->RandomNumbers as $mykey) {
                         $product_rand[$i] = $manufacturers_results[$mykey];
                         $i++;
                     }
                     $results = $product_rand;
                 }
             } else {
                 $results = array();
             }
             $rand->clearrand();
             $product_data = array();
             foreach ($results as $result) {
                 if ($config->get('manufacturerlist_ratings')) {
                     $averageRating = number_format($this->modelProducts->getAverageRating($result['product_id']), 0);
                     $alt_rating = $language->get('text_out_of', $averageRating);
                 } else {
                     $averageRating = NULL;
                     $alt_rating = NULL;
                 }
                 $days_remaining = '';
                 //***
                 if ($result['special_price'] > 0 && date('Y-m-d') >= $result['sale_start_date'] && date('Y-m-d') <= $result['sale_end_date']) {
                     $this->discounted = true;
                     // we have at least 1 price_old div
                     if ($this->discounted && $result['remaining']) {
                         $this->remaining = true;
                         // we have at least 1 remaining div
                     }
                     $number_days = intval((strtotime($result['sale_end_date']) - time()) / 86400);
                     $days_remaining = $language->get($number_days > 1 ? 'days_remaining' : 'day_remaining', $number_days ? $number_days : 1);
                 }
                 if ($result['vendor_id'] != '0' && $config->get('config_unregistered')) {
                     $vendor = $this->modelProducts->get_vendor($result['vendor_id']);
                     $vendor_name = $vendor['name'];
                 } else {
                     $vendor_name = NULL;
                 }
                 if ($columns > 3) {
                     if ($result['alt_description']) {
                         $desc = strippedstring($result['alt_description'], $config->get('manufacturerlist_lines_char'));
                     } else {
                         $desc = strippedstring($result['description'], $config->get('manufacturerlist_lines_char'));
                     }
                     $product_discounts = '';
                     $options = $this->modelProducts->get_option_names($result['product_id']);
                     $product_options = FALSE;
                 } else {
                     if ($result['alt_description']) {
                         $desc = formatedstring($result['alt_description'], $config->get('manufacturerlist_lines_multi'));
                     } else {
                         $desc = formatedstring($result['description'], $config->get('manufacturerlist_lines_multi'));
                     }
                     $product_discounts = '';
                     $options = $this->modelProducts->get_option_names($result['product_id']);
                     $product_options = FALSE;
                 }
                 $product_data[] = array('name' => $result['name'], 'product_id' => $result['product_id'], 'description' => $desc, 'stock_level' => $result['quantity'], 'cart_level' => $cart->hasProduct($result['product_id']), 'min_qty' => $result['min_qty'], 'max_qty' => $result['max_qty'], 'multiple' => $result['multiple'], 'product_discounts' => $product_discounts, 'href' => $url->href('product', FALSE, array('manufacturer_id' => $manufacturer['manufacturer_id'], 'product_id' => $result['product_id'])), 'popup' => $image->href($result['filename']), 'thumb' => $image->resize($result['filename'], $image_width, $image_height), 'special_price' => $currency->format($tax->calculate($result['special_price'], $result['tax_class_id'], $config->get('config_tax'))), 'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $config->get('config_tax'))), 'sale_start_date' => $result['sale_start_date'], 'sale_end_date' => $result['sale_end_date'], 'show_days_remaining' => $result['remaining'], 'options' => $options, 'model_number' => $result['model_number'], 'product_options' => $product_options, 'days_remaining' => $days_remaining, 'average_rating' => $averageRating, 'alt_rating' => $alt_rating, 'vendor_name' => $vendor_name);
             }
             if ($product_data) {
                 $manufacturers_data[$manufacturer['name']] = array('id' => $manufacturer['manufacturer_id'], 'name' => $manufacturer['name'], 'products' => $product_data);
             }
         }
         $view->set('lists', $manufacturers_data);
         $view->set('show_stock', $config->get('config_show_stock'));
         $view->set('show_stock_icon', $config->get('config_show_stock_icon'));
         if ($config->get('config_show_stock_icon')) {
             $view->set('low_stock_warning', $config->get('config_low_stock_warning'));
         }
         $view->set('text_stock_icon', $language->get('text_stock_icon'));
         $view->set('text_soldby', $language->get('text_soldby'));
         $view->set('addtocart_quantity_box', $config->get('addtocart_quantity_box'));
         $view->set('addtocart_quantity_max', $config->get('addtocart_quantity_max'));
         $view->set('slider', $config->get('manufacturerlist_slider'));
         $view->set('text_options', $language->get('text_options'));
         $view->set('Add_to_Cart', $language->get('button_add_to_cart'));
         $view->set('Added_to_Cart', $language->get('button_added_to_cart'));
         $view->set('regular_price', $language->get('regular_price'));
         $view->set('sale_price', $language->get('sale_price'));
         $view->set('addtocart', $config->get('manufacturerlist_addtocart'));
         $view->set('add_enable', $this->modelProducts->currentpage($request->get('controller')));
         $view->set('head_def', $head_def);
         $view->set('image_display', $config->get('manufacturerlist_image_display'));
         $view->set('location', $location);
         $view->set('columns', $columns);
         $view->set('remaining', $this->remaining);
         $view->set('discounted', $this->discounted);
         $view->set('text_quantity_discount', $language->get('text_quantity_discount'));
         $view->set('text_enlarge', $language->get('text_enlarge'));
         $view->set('this_controller', 'manufacturerlist');
         $template->set('head_def', $head_def);
         if ($location == 'content') {
             return $view->fetch('module/module_contentlist.tpl');
         }
     }
 }
 function fetch()
 {
     $cart =& $this->locator->get('cart');
     $config =& $this->locator->get('config');
     $currency =& $this->locator->get('currency');
     $database =& $this->locator->get('database');
     $language =& $this->locator->get('language');
     $image =& $this->locator->get('image');
     $tax =& $this->locator->get('tax');
     $url =& $this->locator->get('url');
     $request =& $this->locator->get('request');
     $template =& $this->locator->get('template');
     $rand =& $this->locator->get('randomnumber');
     $session =& $this->locator->get('session');
     $head_def =& $this->locator->get('HeaderDefinition');
     $this->modelProducts = $this->model->get('model_products');
     $this->modelCore = $this->model->get('model_core');
     require_once 'library/application/string_modify.php';
     if ($config->get('recently_status')) {
         $language->load('extension/module/recently.php');
         $view = $this->locator->create('template');
         $view->set('heading_title', $language->get('heading_title'));
         $view->set('onhand', $language->get('onhand'));
         $view->set('text_model_number', $language->get('text_model_number'));
         $view->set('tax_included', $config->get('config_tax'));
         if ($config->get('recently_slider')) {
             $limit = $config->get('recently_slimit') == '0' ? '' : (int) $config->get('recently_slimit');
             $columns = $config->get('recently_scolumns');
         } else {
             $limit = $config->get('recently_limit') == '0' ? '' : (int) $config->get('recently_limit');
             $columns = $config->get('recently_columns');
         }
         $controller = $this->modelCore->controller;
         // Template Manager
         $location = $this->modelCore->module_location['recently'];
         // Template Manager
         if ($columns == 1 && $location == 'content') {
             $image_width = $config->get('recently_image_width');
             $image_height = $config->get('recently_image_height');
         } else {
             if ($columns <= 3) {
                 $image_width = $config->get('recently_image_width') <= 175 ? $config->get('recently_image_width') : 175;
                 $image_height = $config->get('recently_image_height') <= 175 ? $config->get('recently_image_height') : 175;
             } else {
                 $image_width = $config->get('recently_image_width') <= 140 ? $config->get('recently_image_width') : 140;
                 $image_height = $config->get('recently_image_height') <= 140 ? $config->get('recently_image_height') : 140;
             }
         }
         $view->set('discount_options', $config->get('config_discount_options'));
         //****
         // Currency
         $currency_code = $currency->code;
         $symbol_right = $currency->currencies[$currency_code]['symbol_right'];
         $symbol_left = $currency->currencies[$currency_code]['symbol_left'];
         $view->set('symbols', array($symbol_left, $symbol_right, $language->get('thousand_point')));
         $view->set('price_with_options', $language->get('price_with_options'));
         $view->set('symbol_right', $symbol_right);
         $view->set('symbol_left', $symbol_left);
         $view->set('decimal_point', $language->get('decimal_point'));
         $view->set('thousand_point', $language->get('thousand_point'));
         $view->set('decimal_place', $currency->currencies[$currency_code]['decimal_place']);
         // End Currency
         if (!$session->has('recently')) {
             return;
         } else {
             $recently = $session->get('recently');
             if (count($recently) <= $limit) {
                 $recently = $recently;
             } else {
                 $recently = array_slice($recently, -$limit, $limit);
             }
         }
         $results = $this->modelProducts->get_recently(array_reverse($recently));
         $product_data = array();
         foreach ($results as $result) {
             if ($config->get('recently_ratings')) {
                 $averageRating = number_format($this->modelProducts->getAverageRating($result['product_id']), 0);
                 $alt_rating = $language->get('text_out_of', $averageRating);
             } else {
                 $averageRating = NULL;
                 $alt_rating = NULL;
             }
             $days_remaining = '';
             //***
             if ($result['special_price'] > 0 && date('Y-m-d') >= $result['sale_start_date'] && date('Y-m-d') <= $result['sale_end_date']) {
                 $this->discounted = true;
                 // we have at least 1 price_old div
                 if ($this->discounted && $result['remaining']) {
                     $this->remaining = true;
                     // we have at least 1 remaining div
                 }
                 $number_days = intval((strtotime($result['sale_end_date']) - time()) / 86400);
                 $days_remaining = $language->get($number_days > 1 ? 'days_remaining' : 'day_remaining', $number_days ? $number_days : 1);
             }
             if ($result['vendor_id'] != '0' && $config->get('config_unregistered')) {
                 $vendor = $this->modelProducts->get_vendor($result['vendor_id']);
                 $vendor_name = $vendor['name'];
             } else {
                 $vendor_name = NULL;
             }
             if ($location == 'content' && $columns == 1) {
                 $desc = formatedstring($result['description'], $config->get('recently_lines_single'));
                 // Product Discounts
                 $discounts = $this->modelProducts->get_product_discount($result['product_id']);
                 $product_discounts = array();
                 if ($discounts) {
                     foreach ($discounts as $discount) {
                         if ($result['special_price'] > 0 && date('Y-m-d') >= $result['sale_start_date'] && date('Y-m-d') <= $result['sale_end_date']) {
                             $discount_amount = $result['special_price'] * ($discount['discount'] / 100);
                         } else {
                             $discount_amount = $result['price'] * ($discount['discount'] / 100);
                         }
                         $product_discounts[] = array('discount_quantity' => $discount['quantity'], 'discount_percent' => round($discount['discount'] * 10) / 10, 'discount_amount' => number_format($tax->calculate($discount_amount, $result['tax_class_id'], $config->get('config_tax')), $currency->currencies[$currency_code]['decimal_place'], $language->get('decimal_point'), ''));
                     }
                 }
                 // End product Discounts
                 $options = $this->modelProducts->get_options($result['product_id'], $result['tax_class_id']);
                 $product_options = $this->modelProducts->get_product_with_options($result['product_id'], $image_width, $image_height);
             } else {
                 if ($columns > 3) {
                     if ($result['alt_description']) {
                         $desc = strippedstring($result['alt_description'], $config->get('recently_lines_char'));
                     } else {
                         $desc = strippedstring($result['description'], $config->get('recently_lines_char'));
                     }
                     $product_discounts = '';
                     $options = $this->modelProducts->get_option_names($result['product_id']);
                     $product_options = FALSE;
                 } else {
                     if ($result['alt_description']) {
                         $desc = formatedstring($result['alt_description'], $config->get('recently_lines_multi'));
                     } else {
                         $desc = formatedstring($result['description'], $config->get('recently_lines_multi'));
                     }
                     $product_discounts = '';
                     $options = $this->modelProducts->get_option_names($result['product_id']);
                     $product_options = FALSE;
                 }
             }
             $product_data[] = array('name' => $result['name'], 'product_id' => $result['product_id'], 'description' => $desc, 'stock_level' => $result['quantity'], 'cart_level' => $cart->hasProduct($result['product_id']), 'min_qty' => $result['min_qty'], 'max_qty' => $result['max_qty'], 'multiple' => $result['multiple'], 'product_discounts' => $product_discounts, 'href' => $url->href('product', FALSE, array('product_id' => $result['product_id'])), 'popup' => $image->href($result['filename']), 'thumb' => $image->resize($result['filename'], $image_width, $image_height), 'special_price' => $currency->format($tax->calculate($result['special_price'], $result['tax_class_id'], $config->get('config_tax'))), 'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $config->get('config_tax'))), 'sale_start_date' => $result['sale_start_date'], 'sale_end_date' => $result['sale_end_date'], 'show_days_remaining' => $result['remaining'], 'options' => $options, 'model_number' => $result['model_number'], 'product_options' => $product_options, 'days_remaining' => $days_remaining, 'average_rating' => $averageRating, 'alt_rating' => $alt_rating, 'vendor_name' => $vendor_name);
         }
         if ($product_data) {
             $view->set('products', $product_data);
         } else {
             return;
         }
         $view->set('show_stock', $config->get('config_show_stock'));
         $view->set('show_stock_icon', $config->get('config_show_stock_icon'));
         if ($config->get('config_show_stock_icon')) {
             $view->set('low_stock_warning', $config->get('config_low_stock_warning'));
         }
         $view->set('text_stock_icon', $language->get('text_stock_icon'));
         $view->set('text_soldby', $language->get('text_soldby'));
         $view->set('addtocart_quantity_box', $config->get('addtocart_quantity_box'));
         $view->set('addtocart_quantity_max', $config->get('addtocart_quantity_max'));
         $view->set('slider', $config->get('recently_slider'));
         $view->set('Add_to_Cart', $language->get('button_add_to_cart'));
         $view->set('Added_to_Cart', $language->get('button_added_to_cart'));
         $view->set('regular_price', $language->get('regular_price'));
         $view->set('sale_price', $language->get('sale_price'));
         $view->set('head_def', $head_def);
         $view->set('image_display', $config->get('recently_image_display'));
         $view->set('location', $location);
         $view->set('columns', $columns);
         $view->set('remaining', $this->remaining);
         $view->set('discounted', $this->discounted);
         $view->set('text_options', $language->get('text_options'));
         $view->set('text_quantity_discount', $language->get('text_quantity_discount'));
         $template->set('head_def', $head_def);
         $view->set('add_enable', TRUE);
         $view->set('text_enlarge', $language->get('text_enlarge'));
         $view->set('this_controller', 'recently');
         $view->set('addtocart', $config->get('recently_addtocart'));
         if ($location == 'content') {
             return $view->fetch('module/module_content.tpl');
         } else {
             return $view->fetch('module/module_column.tpl');
         }
     }
 }
 function index()
 {
     $cart =& $this->locator->get('cart');
     $currency =& $this->locator->get('currency');
     $dates = $this->locator->get('dates');
     $this->dimension =& $this->locator->get('dimension');
     $language =& $this->locator->get('language');
     $this->image =& $this->locator->get('image');
     $this->barcode =& $this->locator->get('barcode');
     $request =& $this->locator->get('request');
     $response =& $this->locator->get('response');
     $session =& $this->locator->get('session');
     $shipping =& $this->locator->get('shipping');
     $tax =& $this->locator->get('tax');
     $weight =& $this->locator->get('weight');
     $url =& $this->locator->get('url');
     $head_def =& $this->locator->get('HeaderDefinition');
     require_once 'library/application/string_modify.php';
     if ($request->isPost() && $request->has('product_id', 'post')) {
         $cart->add($request->gethtml('product_id', 'post'), $request->gethtml('quantity', 'post') > 0 ? $request->gethtml('quantity', 'post') : 1, $request->gethtml('option', 'post'));
         $response->redirect($url->href('cart'));
     }
     $language->load('controller/product.php');
     $product_info = $this->modelProducts->getRow_product((int) $request->gethtml('product_id'));
     if ($product_info) {
         $this->modelProducts->update_viewed((int) $request->gethtml('product_id'));
         $breadcrumb = array();
         $breadcrumb[] = array('href' => $url->href('home'), 'text' => $language->get('text_home'), 'separator' => FALSE);
         if ($request->gethtml('path')) {
             foreach (explode('_', $request->gethtml('path')) as $category_id) {
                 $category_info = $this->modelCategory->getRow_category_name($category_id);
                 $breadcrumb[] = array('href' => $url->href('category', FALSE, array('path' => $category_info['path'])), 'text' => $category_info['name'], 'separator' => $language->get('text_separator'));
             }
         }
         if ($request->gethtml('manufacturer_id')) {
             $result = $this->modelProducts->getRow_manufacturer((int) $request->gethtml('manufacturer_id'));
             if ($result) {
                 $breadcrumb[] = array('href' => $url->href('manufacturer', FALSE, array('manufacturer_id' => $request->gethtml('manufacturer_id'))), 'text' => $result['name'], 'separator' => $language->get('text_separator'));
             }
         }
         $query = array('manufacturer_id' => $request->gethtml('manufacturer_id'), 'path' => $request->gethtml('path'), 'product_id' => $request->gethtml('product_id'));
         $breadcrumb[] = array('href' => $url->href('product', FALSE, $query), 'text' => $product_info['name'], 'separator' => $language->get('text_separator'));
         $this->template->set('title', $product_info['name']);
         $view = $this->locator->create('template');
         $view->set('heading_title', $product_info['name']);
         $view->set('breadcrumbs', $breadcrumb);
         $view->set('text_enlarge', $language->get('text_enlarge'));
         $view->set('text_images', $language->get('text_images'));
         $view->set('text_shippable', $language->get('text_shippable'));
         $view->set('text_non_shippable', $language->get('text_non_shippable'));
         $view->set('text_options', $language->get('text_options'));
         $view->set('text_min_qty', $language->get('text_min_qty'));
         $view->set('text_max_qty', $language->get('text_max_qty'));
         $view->set('text_multiple', $language->get('text_multiple'));
         $view->set('text_manufacturer', $language->get('text_manufacturer'));
         $view->set('text_quantity_discount', $language->get('text_quantity_discount'));
         $view->set('text_qty_discount', $language->get('text_qty_discount'));
         $view->set('text_discount', $language->get('text_discount'));
         $view->set('text_sale_start', $language->get('text_sale_start'));
         $view->set('text_sale_end', $language->get('text_sale_end'));
         $view->set('text_date', $language->get('text_date'));
         $view->set('text_shipping_yes', $language->get('text_shipping_yes'));
         $view->set('text_shipping_no', $language->get('text_shipping_no'));
         $view->set('text_review_by', $language->get('text_review_by'));
         $view->set('text_review', $language->get('text_review'));
         $view->set('text_reviews', $language->get('text_reviews'));
         $view->set('text_weight', $language->get('text_weight'));
         $view->set('text_date_added', $language->get('text_date_added'));
         $view->set('text_rating1', $language->get('text_rating1'));
         $view->set('text_rating2', $language->get('text_rating2'));
         $view->set('text_rating3', $language->get('text_rating3'));
         $view->set('text_rating4', $language->get('text_rating4'));
         $view->set('text_rateit', $language->get('text_rateit'));
         $view->set('text_error', $language->get('text_empty'));
         $view->set('text_model_number', $language->get('text_model_number'));
         $view->set('text_soldby', $language->get('text_soldby'));
         $view->set('text_downloadable', $language->get('text_downloadable'));
         $view->set('text_product_download', $language->get('text_product_download'));
         $view->set('text_product_detail', $language->get('text_product_detail'));
         $view->set('text_barcode', $language->get('text_barcode'));
         $view->set('text_stock_icon', $language->get('text_stock_icon'));
         $view->set('text_barcode_img', $language->get('text_barcode_img'));
         $view->set('text_free_downloads', $language->get('text_free_downloads'));
         $view->set('button_reviews', $language->get('button_reviews'));
         $view->set('button_add_to_cart', $language->get('button_add_to_cart'));
         //			$view->set('product_number', $language->get('product_number'));
         $view->set('quantity_available', $language->get('quantity_available'));
         $view->set('standard_price', $language->get('standard_price'));
         $view->set('tab_description', $language->get('tab_description'));
         $view->set('tab_images', $language->get('tab_images'));
         $view->set('tab_information', $language->get('tab_information'));
         $view->set('tab_reviews', $language->get('tab_reviews'));
         $view->set('tab_write', $language->get('tab_write'));
         $view->set('tab_technical', $product_info['technical_name'] ? $product_info['technical_name'] : $language->get('tab_technical'));
         $view->set('tax_included', $this->config->get('config_tax'));
         $view->set('text_tax_rate', ($this->config->get('config_tax') ? $language->get('text_tax_included') : '') . $language->get('text_tax_rate'));
         $query = array('path' => $request->gethtml('path'), 'product_id' => $request->gethtml('product_id'));
         $view->set('action', $url->href('product', FALSE, $query));
         if (!$session->has('recently')) {
             $session->set('recently', $recently = array((int) $request->gethtml('product_id')));
         } else {
             $recently = $session->get('recently');
             $key = array_search((int) $request->gethtml('product_id'), $recently);
             if ($key !== FALSE) {
                 unset($recently[$key]);
                 array_values($recently);
             }
             $recently[] = (int) $request->gethtml('product_id');
             $session->set('recently', $recently);
         }
         $dimension_class = $this->modelProducts->get_dimension_class($product_info['dimension_id']);
         $dimension_value = $this->dimension->getValues($product_info['dimension_value'], $dimension_class['type_id'], $product_info['dimension_id']);
         $view->set('dimensions', $this->modelProducts->dimensionView($dimension_class, $dimension_value));
         $view->set('shipping', $product_info['shipping']);
         $shipping_time = $product_info['shipping_time_from'] === $product_info['shipping_time_to'] ? $product_info['shipping_time_from'] : $product_info['shipping_time_from'] . ' - ' . $product_info['shipping_time_to'];
         $view->set('shipping_time', $shipping_time);
         $view->set('text_shipping_time', $language->get('text_shipping_time', $shipping_time));
         $view->set('description', formatedstring($product_info['description'], 40));
         $view->set('technical', formatedstring($product_info['technical'], 40));
         if ($product_info['alt_description'] && $this->config->get('alternate_description')) {
             $view->set('alt_description', formatedstring($product_info['alt_description'], 4));
         }
         $view->set('onhand', $language->get('onhand'));
         $view->set('Add_to_Cart', $language->get('button_add_to_cart'));
         $view->set('Added_to_Cart', $language->get('button_added_to_cart'));
         $view->set('regular_price', $language->get('regular_price'));
         $view->set('sale_price', $language->get('sale_price'));
         $view->set('stock_level', $product_info['quantity']);
         $view->set('meta_title', $product_info['meta_title']);
         $view->set('meta_description', $product_info['meta_description']);
         $view->set('meta_keywords', $product_info['meta_keywords']);
         $view->set('product_options_select', $this->config->get('product_options_select'));
         // New manufaturer
         if ($this->config->get('manufacturer_status')) {
             $result = $this->modelProducts->getRow_manufacturer((int) $product_info['manufacturer_id']);
             if ($result) {
                 $manufacturer = array('name' => $result['name'], 'href' => $url->href('manufacturer', FALSE, array('manufacturer_id' => $result['manufacturer_id'])));
                 $view->set('manufacturer', $manufacturer);
             }
         }
         // Currency
         $currency_code = $currency->code;
         $symbol_right = $currency->currencies[$currency_code]['symbol_right'];
         $symbol_left = $currency->currencies[$currency_code]['symbol_left'];
         $view->set('symbols', array($symbol_left, $symbol_right, $language->get('thousand_point')));
         // **************
         $view->set('price_with_options', $language->get('price_with_options'));
         $view->set('symbol_right', $symbol_right);
         $view->set('symbol_left', $symbol_left);
         $view->set('decimal_place', $currency->currencies[$currency_code]['decimal_place']);
         $view->set('decimal_point', $language->get('decimal_point'));
         //********
         $view->set('thousand_point', $language->get('thousand_point'));
         //*****************
         $view->set('tax_rate', round($tax->getRate($product_info['tax_class_id'], $currency->currencies[$currency_code]['decimal_place'])) . '%');
         $product_weight = $weight->convert($product_info['weight'], $product_info['weight_class_id'], $this->config->get('config_weight_class_id'));
         $product_weight = number_format($product_weight, $this->config->get('config_weight_decimal'), $language->get('decimal_point'), '');
         $view->set('weight', $product_weight);
         $view->set('weight_unit', $weight->getClass($this->config->get('config_weight_class_id')));
         $view->set('weight_decimal', $this->config->get('config_weight_decimal'));
         $view->set('option_weights', $this->modelProducts->get_option_weight($product_info['product_id'], $this->config->get('config_weight_class_id')));
         //  Product Discounts
         $view->set('discount_options', $this->config->get('config_discount_options'));
         $results = $this->modelProducts->get_product_discount((int) $request->gethtml('product_id'));
         $product_discounts = array();
         if ($results) {
             foreach ($results as $result) {
                 if ($product_info['special_price'] > 0 && date('Y-m-d') >= $product_info['sale_start_date'] && date('Y-m-d') <= $product_info['sale_end_date']) {
                     $discount_amount = $product_info['special_price'] * ($result['discount'] / 100);
                 } else {
                     $discount_amount = $product_info['price'] * ($result['discount'] / 100);
                 }
                 $product_discounts[] = array('discount_quantity' => $result['quantity'], 'discount_percent' => round($result['discount'] * 10) / 10, 'discount_amount' => number_format($tax->calculate($discount_amount, $product_info['tax_class_id'], $this->config->get('config_tax')), $currency->currencies[$currency_code]['decimal_place'], $language->get('decimal_point'), ''));
             }
             $view->set('product_discounts', $product_discounts);
         }
         $image_data = array();
         // Additional Images
         $results = $this->modelProducts->get_additional_images((int) $request->gethtml('product_id'));
         foreach ($results as $result) {
             $image_data[] = array('image_id' => $result['image_id'], 'title' => $result['title'], 'popup' => $this->image->href($result['filename']), 'thumb' => $this->image->resize($result['filename'], $this->config->get('additional_image_width'), $this->config->get('additional_image_height')));
         }
         $downloads = $this->modelProducts->get_downloads($request->gethtml('product_id'));
         $view->set('downloads', $downloads);
         $this->fdownloads = $this->modelProducts->get_fdownloads($request->gethtml('product_id'));
         $view->set('fdownloads', $this->fdownloads);
         $days_remaining = '';
         //***
         if ($product_info['special_price'] > 0 && date('Y-m-d') >= $product_info['sale_start_date'] && date('Y-m-d') <= $product_info['sale_end_date']) {
             $number_days = intval((strtotime($product_info['sale_end_date']) - time()) / 86400);
             $days_remaining = $language->get($number_days > 1 ? 'days_remaining' : 'day_remaining', $number_days ? $number_days : 1);
             //*****
             $view->set('sale_start', $dates->getDate($language->get('date_format_short'), strtotime($product_info['sale_start_date'])));
             $view->set('sale_end', $dates->getDate($language->get('date_format_short'), strtotime($product_info['sale_end_date'])));
         }
         if ($product_info['vendor_id'] != '0' && $this->config->get('config_unregistered')) {
             $vendor = $this->modelProducts->get_vendor($product_info['vendor_id']);
             $vendor_name = $vendor['name'];
         } else {
             $vendor_name = NULL;
         }
         if ($this->config->get('review_status')) {
             $averageRating = number_format($this->modelProducts->getAverageRating($request->gethtml('product_id')), 0);
         }
         $product_data = array('product_id' => $request->gethtml('product_id'), 'thumb' => $this->image->resize($product_info['filename'], $this->config->get('product_image_width'), $this->config->get('product_image_height')), 'name' => $product_info['name'], 'model_number' => $product_info['model_number'], 'vendor_name' => $vendor_name, 'barcode' => $product_info['barcode'], 'barcode_url' => $product_info['barcode'] ? $this->barcode->show($product_info['barcode']) : NULL, 'popup' => $this->image->href($product_info['filename']), 'min_qty' => isset($product_info['min_qty']) ? $product_info['min_qty'] : 1, 'max_qty' => isset($product_info['max_qty']) ? $product_info['max_qty'] : 0, 'multiple' => isset($product_info['multiple']) ? $product_info['multiple'] : 0, 'cart_level' => $cart->hasProduct($request->gethtml('product_id')), 'special_price' => $currency->format($tax->calculate($product_info['special_price'], $product_info['tax_class_id'], $this->config->get('config_tax'))), 'price' => $currency->format($tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))), 'sale_start_date' => $product_info['sale_start_date'], 'sale_end_date' => $product_info['sale_end_date'], 'show_days_remaining' => $product_info['remaining'], 'options' => $this->modelProducts->get_options($product_info['product_id'], $product_info['tax_class_id']), 'days_remaining' => $days_remaining);
         $view->set('product', $product_data);
         if ($this->config->get('review_status')) {
             $view->set('review_status', true);
             $view->set('text_write', $language->get('text_write'));
             $view->set('text_write_short', $language->get('text_write_short'));
             $view->set('write', $url->href('review_write', false, array('product_id' => $request->gethtml('product_id'))));
             $view->set('average_rating', $averageRating);
             $view->set('alt_rating', $language->get('text_out_of', $averageRating));
         } else {
             $view->set('review_status', false);
         }
         $view->set('review_data', $this->review());
         $view->set('show_stock', $this->config->get('config_show_stock'));
         $view->set('show_stock_icon', $this->config->get('config_show_stock_icon'));
         if ($this->config->get('config_show_stock_icon')) {
             $view->set('low_stock_warning', $this->config->get('config_low_stock_warning'));
         }
         $view->set('social', $this->config->get('config_social'));
         $view->set('current_product', $url->current_page());
         $view->set('addtocart_quantity_box', $this->config->get('addtocart_quantity_box'));
         $view->set('addtocart_quantity_max', $this->config->get('addtocart_quantity_max'));
         $view->set('maxrow', count($this->review()));
         $view->set('images', $image_data);
         $view->set('image_display', $this->config->get('product_image_display'));
         $view->set('magnifier', $this->config->get('magnifier'));
         $view->set('magnifier_width', $this->config->get('magnifier_width'));
         $view->set('magnifier_height', $this->config->get('magnifier_height'));
         $view->set('head_def', $head_def);
         $view->set('product_addtocart', $this->config->get('product_addtocart'));
         $view->set('columns', 1);
         $view->set('product_options', $this->modelProducts->get_product_with_options($product_info['product_id'], $this->config->get('product_image_width'), $this->config->get('product_image_height')));
         $view->set('this_controller', 'product');
         $this->template->set('head_def', $head_def);
         $this->has_related = $product_info['related'];
         $view->set('freedownload', $this->config->get('config_freedownload'));
         $this->template->set('content', $view->fetch('content/product.tpl'));
     } else {
         $this->template->set('title', $language->get('text_error'));
         $view = $this->locator->create('template');
         $view->set('heading_title', $language->get('text_error'));
         $view->set('text_error', $language->get('text_error'));
         $view->set('button_continue', $language->get('button_continue'));
         $view->set('continue', $url->href('home'));
         $this->template->set('content', $view->fetch('content/error.tpl'));
     }
     $this->load_modules();
     // Template Manager
     $this->set_tpl_modules();
     // Template Manager
     $this->template->set($this->module->fetch());
     $response->set($this->template->fetch('layout.tpl'));
 }