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