bestseller.php (2320B)
1 <?php 2 class ControllerExtensionModuleBestSeller extends Controller { 3 public function index($setting) { 4 $this->load->language('extension/module/bestseller'); 5 6 $this->load->model('catalog/product'); 7 8 $this->load->model('tool/image'); 9 10 $data['products'] = array(); 11 12 $results = $this->model_catalog_product->getBestSellerProducts($setting['limit']); 13 14 if ($results) { 15 foreach ($results as $result) { 16 if ($result['image']) { 17 $image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']); 18 } else { 19 $image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']); 20 } 21 22 if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { 23 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); 24 } else { 25 $price = false; 26 } 27 28 if ((float)$result['special']) { 29 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']); 30 } else { 31 $special = false; 32 } 33 34 if ($this->config->get('config_tax')) { 35 $tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price'], $this->session->data['currency']); 36 } else { 37 $tax = false; 38 } 39 40 if ($this->config->get('config_review_status')) { 41 $rating = $result['rating']; 42 } else { 43 $rating = false; 44 } 45 46 $data['products'][] = array( 47 'product_id' => $result['product_id'], 48 'thumb' => $image, 49 'name' => $result['name'], 50 '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')) . '..', 51 'price' => $price, 52 'special' => $special, 53 'tax' => $tax, 54 'rating' => $rating, 55 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']) 56 ); 57 } 58 59 return $this->load->view('extension/module/bestseller', $data); 60 } 61 } 62 }