Exemplo n.º 1
0
 function fetch()
 {
     $config =& $this->locator->get('config');
     $head_def =& $this->locator->get('HeaderDefinition');
     $image =& $this->locator->get('image');
     $language =& $this->locator->get('language');
     $request =& $this->locator->get('request');
     $template =& $this->locator->get('template');
     $url =& $this->locator->get('url');
     $this->modelReview = $this->model->get('model_review');
     $this->modelCore = $this->model->get('model_core');
     require_once 'library/application/string_modify.php';
     if ($config->get('review_status')) {
         $controller = $this->modelCore->controller;
         // Template Manager
         $location = $this->modelCore->module_location['review'];
         // Template Manager
         $review_info = $this->modelReview->get_review();
         if ($review_info) {
             $language->load('extension/module/review.php');
             $view = $this->locator->create('template');
             $view->set('heading_title', $language->get('heading_title'));
             $average = ($review_info['rating1'] + $review_info['rating2'] + $review_info['rating3'] + $review_info['rating4']) / 4;
             $avgrating = number_format($average, 0);
             $avgrating2 = number_format($average, 1);
             $view->set('text_rating', $language->get('text_rating', $avgrating));
             $view->set('name', $review_info['name']);
             $view->set('rating', $avgrating);
             $view->set('avgrating', $avgrating2);
             $view->set('desciption', strippedstring($review_info['text'], 55));
             $view->set('image', $image->resize($review_info['filename'], $config->get('config_image_width'), $config->get('config_image_height')));
             $view->set('review', $url->href('review_info', false, array('product_id' => $review_info['product_id'], 'review_id' => $review_info['review_id'])));
             $view->set('reviews', $url->href('review'));
             $template->set('head_def', $head_def);
             $view->set('head_def', $head_def);
             return $view->fetch('module/review.tpl');
         } else {
             return;
         }
     }
 }
Exemplo n.º 2
0
 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'));
 }
Exemplo n.º 3
0
    case 'rss_featured':
        $sql = "select *, p.date_added as date_product_added from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '%s' and p.date_available < now() and p.status = '1' and p.featured = '1' order by date_product_added desc limit " . $limit;
        break;
    case 'rss_specials':
        $sql = "select *, p.date_added as date_product_added from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '%s' and p.date_available < now() and p.status = '1' and p.special_offer = '1' order by date_product_added desc limit " . $limit;
        break;
    case 'rss_popular':
        $sql = "select *, p.date_added as date_product_added from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '%s' and p.date_available < now() and p.status = '1' order by viewed desc limit " . $limit;
        break;
}
$sql = sprintf($sql, (int) $language->getId());
$results = $database->getRows($sql);
$unit = 'Pounds';
$products = array();
foreach ($results as $result) {
    $products[] = array('name' => strip_tags($result['name']), 'url' => $url->href('product', FALSE, array('product_id' => $result['product_id'])), 'add_date' => date("D, d M Y H:i:s T", strtotime($result['date_product_added'])), 'desc' => htmlentities(strip_tags(strippedstring($result['description'], 256), 'ENT_QUOTES')) . htmlentities('<br>'), 'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $config->get('config_tax'))), 'image' => htmlentities('<br><img width="100" height="100" src="' . $image->resize($result['filename'], 100, 100) . '">'), 'weight' => $result['weight'] . ' ' . $unit);
}
header('Content-type: text/xml');
?>
<rss version="2.0">
<channel>
	<title><?php 
echo $config->get('config_store');
?>
</title>
	<description><?php 
echo $config->get('config_store');
?>
</description>
	<link><?php 
echo $catalog_url;
Exemplo n.º 4
0
 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');
         }
     }
 }
Exemplo n.º 5
0
    case 'rss_featured':
        $sql = "select *, p.date_added as date_product_added from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '%s' and p.date_available < now() and p.status = '1' and p.featured = '1' order by date_product_added desc limit " . $limit;
        break;
    case 'rss_specials':
        $sql = "select *, p.date_added as date_product_added from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '%s' and p.date_available < now() and p.status = '1' and p.special_offer = '1' order by date_product_added desc limit " . $limit;
        break;
    case 'rss_popular':
        $sql = "select *, p.date_added as date_product_added from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '%s' and p.date_available < now() and p.status = '1' order by viewed desc limit " . $limit;
        break;
}
$sql = sprintf($sql, (int) $language->getId());
$results = $database->getRows($sql);
$products = array();
foreach ($results as $result) {
    $manufacturer = $database->getRow("select * from manufacturer where manufacturer_id = '" . (int) $result['manufacturer_id'] . "'");
    $products[] = array('name' => strip_tags($result['name']), 'url' => $url->href('product', FALSE, array('product_id' => $result['product_id'])), 'add_date' => date("D, d M Y H:i:s T", strtotime($result['date_product_added'])), 'desc' => htmlentities(strip_tags(strippedstring($result['description'], 256), 'ENT_QUOTES')), 'quantity' => $result['quantity'], 'thumb' => $image->resize($result['filename'], 200, 200), 'id' => $result['product_id'], 'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $config->get('config_tax'))), 'model' => htmlentities($result['model']), 'manufacturer' => $manufacturer['name'], 'weight' => $weight->format($weight->convert($result['weight'], $result['weight_class_id'], $config->get('config_weight_class_id')), $config->get('config_weight_class_id')));
}
header('Content-type: text/xml');
echo '<?xml version="1.0"?>';
?>
<rss version="2.0"
xmlns:g="http://base.google.com/ns/1.0">
<channel>
	<title><?php 
echo $config->get('config_store');
?>
</title>
	<description><?php 
echo $config->get('config_store');
?>
</description>
 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');
         }
     }
 }