aboutsummaryrefslogtreecommitdiffstats
path: root/public/catalog/controller/extension/module/bestseller.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/catalog/controller/extension/module/bestseller.php')
-rw-r--r--public/catalog/controller/extension/module/bestseller.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/public/catalog/controller/extension/module/bestseller.php b/public/catalog/controller/extension/module/bestseller.php
new file mode 100644
index 0000000..6b0a239
--- /dev/null
+++ b/public/catalog/controller/extension/module/bestseller.php
@@ -0,0 +1,62 @@
+<?php
+class ControllerExtensionModuleBestSeller extends Controller {
+ public function index($setting) {
+ $this->load->language('extension/module/bestseller');
+
+ $this->load->model('catalog/product');
+
+ $this->load->model('tool/image');
+
+ $data['products'] = array();
+
+ $results = $this->model_catalog_product->getBestSellerProducts($setting['limit']);
+
+ if ($results) {
+ foreach ($results as $result) {
+ if ($result['image']) {
+ $image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
+ } else {
+ $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
+ }
+
+ if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
+ $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
+ } else {
+ $price = false;
+ }
+
+ if ((float)$result['special']) {
+ $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
+ } else {
+ $special = false;
+ }
+
+ if ($this->config->get('config_tax')) {
+ $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']);
+ } else {
+ $tax = false;
+ }
+
+ if ($this->config->get('config_review_status')) {
+ $rating = $result['rating'];
+ } else {
+ $rating = false;
+ }
+
+ $data['products'][] = array(
+ 'product_id' => $result['product_id'],
+ 'thumb' => $image,
+ 'name' => $result['name'],
+ 'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
+ 'price' => $price,
+ 'special' => $special,
+ 'tax' => $tax,
+ 'rating' => $rating,
+ 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'])
+ );
+ }
+
+ return $this->load->view('extension/module/bestseller', $data);
+ }
+ }
+}