shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

featured.php (2654B)


      1 <?php
      2 class ControllerExtensionModuleFeatured extends Controller {
      3 	public function index($setting) {
      4 		$this->load->language('extension/module/featured');
      5 
      6 		$this->load->model('catalog/product');
      7 
      8 		$this->load->model('tool/image');
      9 
     10 		$data['products'] = array();
     11 
     12 		if (!$setting['limit']) {
     13 			$setting['limit'] = 4;
     14 		}
     15 
     16 		if (!empty($setting['product'])) {
     17 			$products = array_slice($setting['product'], 0, (int)$setting['limit']);
     18 
     19 			foreach ($products as $product_id) {
     20 				$product_info = $this->model_catalog_product->getProduct($product_id);
     21 
     22 				if ($product_info) {
     23 					if ($product_info['image']) {
     24 						$image = $this->model_tool_image->resize($product_info['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($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
     31 					} else {
     32 						$price = false;
     33 					}
     34 
     35 					if ((float)$product_info['special']) {
     36 						$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['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)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']);
     43 					} else {
     44 						$tax = false;
     45 					}
     46 
     47 					if ($this->config->get('config_review_status')) {
     48 						$rating = $product_info['rating'];
     49 					} else {
     50 						$rating = false;
     51 					}
     52 
     53 					$data['products'][] = array(
     54 						'product_id'  => $product_info['product_id'],
     55 						'thumb'       => $image,
     56 						'name'        => $product_info['name'],
     57 						'description' => utf8_substr(strip_tags(html_entity_decode($product_info['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=' . $product_info['product_id'])
     63 					);
     64 				}
     65 			}
     66 		}
     67 
     68 		if ($data['products']) {
     69 			return $this->load->view('extension/module/featured', $data);
     70 		}
     71 	}
     72 }