catalog/controller/module/featured.php
Code: Select all
<?php
class ControllerModuleFeatured extends Controller {
protected function index($setting) {
$this->language->load('module/featured');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['button_cart'] = $this->language->get('button_cart');
$this->load->model('catalog/product');
$this->load->model('tool/image');
$this->data['products'] = array();
$products = explode(',', $this->config->get('featured_product'));
if (empty($setting['limit'])) {
$setting['limit'] = 5;
}
if ($this->config->get('config_catalog_mode')) {
$this->data['catalog_mode'] = true;
} else {
$this->data['catalog_mode'] = false;
}
$products = array_slice($products, 0, (int)$setting['limit']);
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
$s = "SELECT * FROM ".DB_PREFIX."product_to_category pc LEFT JOIN ".DB_PREFIX."category c ON (pc.category_id = c.category_id) LEFT JOIN ".DB_PREFIX."category_description cd ON (c.category_id = cd.category_id) WHERE pc.product_id = '".(int)$result['product_id']."' AND c.parent_id = 25";
$r = $this->db->query($s);
$descr = mb_substr(strip_tags(html_entity_decode($product_info['description'])), 0, 770) . '..';
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $product_info['rating'];
} else {
$rating = false;
}
$this->data['products'][] = array(
'description' => $descr,
'location' => $r->row['name'],
'location_href' => $this->url->link('product/category', 'path='.$r->row['category_id'], 'SSL'),
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
);
}
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/featured.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/featured.tpl';
} else {
$this->template = 'default/template/module/featured.tpl';
}
$this->render();
}
}
?>
catalog/controller/module/latest.php
Code: Select all
<?php
class ControllerModuleLatest extends Controller {
protected function index($setting) {
$this->language->load('module/latest');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['button_cart'] = $this->language->get('button_cart');
$this->load->model('catalog/product');
$this->load->model('tool/image');
$this->data['products'] = array();
$data = array(
'sort' => 'p.date_added',
'order' => 'DESC',
'start' => 0,
'limit' => $setting['limit']
);
if ($this->config->get('config_catalog_mode')) {
$this->data['catalog_mode'] = true;
} else {
$this->data['catalog_mode'] = false;
}
$results = $this->model_catalog_product->getProducts($data);
foreach ($results as $result) {
$s = "SELECT * FROM ".DB_PREFIX."product_to_category pc LEFT JOIN ".DB_PREFIX."category c ON (pc.category_id = c.category_id) LEFT JOIN ".DB_PREFIX."category_description cd ON (c.category_id = cd.category_id) WHERE pc.product_id = '".(int)$result['product_id']."' AND c.parent_id = 25";
$r = $this->db->query($s);
$product_info = $this->model_catalog_product->getProduct($result['product_id']);
$descr = mb_substr(strip_tags(html_entity_decode($product_info['description'])), 0, 770) . '..';
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['image_width'], $setting['image_height']);
} else {
$image = false;
}
if (($this->config->get('config_customer_price') && $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')));
} 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')));
} else {
$special = false;
}
if ($this->config->get('config_review_status')) {
$rating = $result['rating'];
} else {
$rating = false;
}
$this->data['products'][] = array(
'description' => $descr,
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'location' => $r->row['name'],
'location_href' => $this->url->link('product/category', 'path='.$r->row['category_id'], 'SSL'),
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/latest.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/latest.tpl';
} else {
$this->template = 'default/template/module/latest.tpl';
}
$this->render();
}
}
?>
Code: Select all
<div class="box">
<div class="box-heading" style="color:#000;font-size: 14pt;"><?php echo $heading_title; ?></div>
</div>
<?php foreach ($products as $product) { ?>
<div class="box-latest">
<div class="box-heading-latest"><div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a><span style="float: right;"><a href="<?php echo $product['location_href']; ?>"><?php echo $product['location']; ?></a></span></div></div>
<div class="box-content-latest">
<div class="box-product-latest">
<table class="table" style="width: 100%;border: 1px solid #7C7C7C;">
<tr>
<td class="center" style="vertical-align: top; width: 15%;">
<?php if ($product['thumb']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
<?php } ?>
</td>
<td class="left" style="vertical-align: top; width:auto;">
<?php echo $product['description']; ?>
</td>
<td style="vertical-align: top;">
<?php if ($product['rating']) { ?>
<div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
<?php } ?>
</td>
</tr>
</table> </div>
</div>
<div class="box-heading-latest"><div class="name"><a href="<?php echo $product['href']; ?>">Още</a></div></div>
</div>
<?php } ?>