If you are using the SEO module, you will likely need to do something like the following: http://stackoverflow.com/questions/7578 ... n-opencart
This was all that was needed for my site to get this module up and running.
This was all that was needed for my site to get this module up and running.
I've made some little fixes and made it run on 1.5.3.1 but..
Only a single products shows on the page.
What might be the problem?
Here is the code:
catalog/view/theme/hyla/template/product/latest.tpl
catalog/language/english/product/latest.php
Only a single products shows on the page.
What might be the problem?
Here is the code:
catalog/view/theme/hyla/template/product/latest.tpl
Code: Select all
<?php echo $header; ?><div id="contentwrapper"><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
<div class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
<?php } ?>
</div>
<h1><?php echo $heading_title; ?></h1>
<?php if ($products) { ?>
<div class="product-filter">
<div class="display"><b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display('grid');"><?php echo $text_grid; ?></a></div>
<div class="limit"><?php echo $text_limit; ?>
<select onchange="location = this.value;">
<?php foreach ($limits as $limits) { ?>
<?php if ($limits['value'] == $limit) { ?>
<option value="<?php echo $limits['href']; ?>" selected="selected"><?php echo $limits['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $limits['href']; ?>"><?php echo $limits['text']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="sort"><?php echo $text_sort; ?>
<select onchange="location = this.value;">
<?php foreach ($sorts as $sorts) { ?>
<?php if ($sorts['value'] == $sort . '-' . $order) { ?>
<option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
<div class="product-compare"><a href="<?php echo $compare; ?>" id="compare-total"><?php echo $text_compare; ?></a></div>
<div class="product-list">
<?php foreach ($products as $product) { ?>
<div>
<?php if ($product['thumb']) { ?>
<div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
<?php } ?>
<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
<div class="description"><?php echo $product['description']; ?></div>
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<br />
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['rating']) { ?>
<div class="rating"><img src="catalog/view/theme/hyla/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
<?php } ?>
<div class="cart"><input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" /></div>
<div class="wishlist"><a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a></div>
<div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
</div>
<?php } ?>
</div>
<div class="pagination"><?php echo $pagination; ?></div>
<?php } else { ?>
<div class="content"><?php echo $text_empty; ?></div>
<?php }?>
<?php echo $content_bottom; ?></div></div>
<script type="text/javascript"><!--
function display(view) {
if (view == 'list') {
$('.product-grid').attr('class', 'product-list');
$('.product-list > div').each(function(index, element) {
html = '<div class="right">';
html += '</div>';
html += '<div class="left">';
var image = $(element).find('.image').html();
if (image != null) {
html += '<div class="image">' + image + '</div>';
}
var price = $(element).find('.price').html();
html += ' <div class="cart">' + $(element).find('.cart').html() + '</div>';
if (price != null) {
html += '<div class="price">' + price + '</div>';
}
html += ' <div class="name">' + $(element).find('.name').html() + '</div>';
html += ' <div class="description">' + $(element).find('.description').html() + '</div>';
html += ' <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
html += ' <div class="compare">' + $(element).find('.compare').html() + '</div>';
html += '</div>';
$(element).html(html);
});
$('.display').html('<b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <img src="catalog/view/theme/hyla/image/product-list.png" alt="<?php echo $text_list; ?>" title="<?php echo $text_list; ?>" /> <b>/</b> <a onclick="display(\'grid\');"><?php echo $text_grid; ?></a> <img src="catalog/view/theme/hyla/image/product-grid.png" alt="<?php echo $text_grid; ?>" title="<?php echo $text_grid; ?>" onclick="display(\'grid\');"/>');
$.cookie('display', 'list');
} else {
$('.product-list').attr('class', 'product-grid');
$('.product-grid > div').each(function(index, element) {
html = '';
var image = $(element).find('.image').html();
if (image != null) {
html += '<div class="image">' + image + '</div>';
}
html += '<div class="name">' + $(element).find('.name').html() + '</div>';
html += '<div class="description">' + $(element).find('.description').html() + '</div>';
var price = $(element).find('.price').html();
if (price != null) {
html += '<div class="price">' + price + '</div>';
}
html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
$(element).html(html);
});
$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><?php echo $text_list; ?></a> <img src="catalog/view/theme/hyla/image/product-list.png" alt="<?php echo $text_list; ?>" title="<?php echo $text_list; ?>" onclick="display(\'list\');"/> <b>/</b> <?php echo $text_grid; ?> <img src="catalog/view/theme/hyla/image/product-grid.png" alt="<?php echo $text_grid; ?>" title="<?php echo $text_grid; ?>"/>');
$.cookie('display', 'grid');
}
}
view = $.cookie('display');
if (view) {
display(view);
} else {
display('list');
}
//--></script>
<?php echo $footer; ?>
Code: Select all
<?php
// Heading
$_['heading_title'] = 'New Arrivals';
// Text
$_['text_empty'] = 'There are no new products in the list.';
$_['text_quantity'] = 'Qty:';
$_['text_manufacturer'] = 'Brand:';
$_['text_model'] = 'Product Code:';
$_['text_points'] = 'Reward Points:';
$_['text_price'] = 'Price:';
$_['text_tax'] = 'Ex Tax:';
$_['text_reviews'] = 'Based on %s reviews.';
$_['text_compare'] = 'Product Compare (%s)';
$_['text_display'] = 'Display:';
$_['text_list'] = 'List';
$_['text_grid'] = 'Grid';
$_['text_sort'] = 'Sort By:';
$_['text_default'] = 'Default';
$_['text_name_asc'] = 'Name (A - Z)';
$_['text_name_desc'] = 'Name (Z - A)';
$_['text_price_asc'] = 'Price (Low > High)';
$_['text_price_desc'] = 'Price (High > Low)';
$_['text_rating_asc'] = 'Rating (Lowest)';
$_['text_rating_desc'] = 'Rating (Highest)';
$_['text_model_asc'] = 'Model (A - Z)';
$_['text_model_desc'] = 'Model (Z - A)';
$_['text_limit'] = 'Show:';
?>
catalog/controller/product/latest.php
Code: Select all
<?php
class ControllerProductLatest extends Controller {
public function index() {
$this->language->load('product/latest');
$this->load->model('catalog/product');
$this->load->model('tool/image');
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
} else {
$limit = $this->config->get('config_catalog_limit');
}
$this->document->setTitle($this->language->get('heading_title'));
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('product/latest', $url),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_empty'] = $this->language->get('text_empty');
$this->data['text_quantity'] = $this->language->get('text_quantity');
$this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
$this->data['text_model'] = $this->language->get('text_model');
$this->data['text_price'] = $this->language->get('text_price');
$this->data['text_tax'] = $this->language->get('text_tax');
$this->data['text_points'] = $this->language->get('text_points');
$this->data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));
$this->data['text_display'] = $this->language->get('text_display');
$this->data['text_list'] = $this->language->get('text_list');
$this->data['text_grid'] = $this->language->get('text_grid');
$this->data['text_sort'] = $this->language->get('text_sort');
$this->data['text_limit'] = $this->language->get('text_limit');
$this->data['button_cart'] = $this->language->get('button_cart');
$this->data['button_wishlist'] = $this->language->get('button_wishlist');
$this->data['button_compare'] = $this->language->get('button_compare');
$this->data['compare'] = $this->url->link('product/compare');
$this->data['products'] = array();
$data = array(
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $limit,
'limit' => $limit
);
$product_total = $this->model_catalog_product->getTotalProductSpecials($data);
$results = $this->model_catalog_product->getLatestProducts($data);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_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_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', $url . '&product_id=' . $result['product_id'])
);
}
$url = '';
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$this->data['sorts'] = array();
$this->data['sorts'][] = array(
'text' => $this->language->get('text_default'),
'value' => 'p.sort_order-ASC',
'href' => $this->url->link('product/latest', 'sort=p.sort_order&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_asc'),
'value' => 'pd.name-ASC',
'href' => $this->url->link('product/latest', 'sort=pd.name&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_desc'),
'value' => 'pd.name-DESC',
'href' => $this->url->link('product/latest', 'sort=pd.name&order=DESC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_asc'),
'value' => 'ps.price-ASC',
'href' => $this->url->link('product/latest', 'sort=ps.price&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_desc'),
'value' => 'ps.price-DESC',
'href' => $this->url->link('product/latest', 'sort=ps.price&order=DESC' . $url)
);
if ($this->config->get('config_review_status')) {
$this->data['sorts'][] = array(
'text' => $this->language->get('text_rating_desc'),
'value' => 'rating-DESC',
'href' => $this->url->link('product/latest', 'sort=rating&order=DESC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_rating_asc'),
'value' => 'rating-ASC',
'href' => $this->url->link('product/latest', 'sort=rating&order=ASC' . $url)
);
}
$this->data['sorts'][] = array(
'text' => $this->language->get('text_model_asc'),
'value' => 'p.model-ASC',
'href' => $this->url->link('product/latest', 'sort=p.model&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_model_desc'),
'value' => 'p.model-DESC',
'href' => $this->url->link('product/latest', 'sort=p.model&order=DESC' . $url)
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
$this->data['limits'] = array();
$this->data['limits'][] = array(
'text' => $this->config->get('config_catalog_limit'),
'value' => $this->config->get('config_catalog_limit'),
'href' => $this->url->link('product/latest', $url . '&limit=' . $this->config->get('config_catalog_limit'))
);
$this->data['limits'][] = array(
'text' => 25,
'value' => 25,
'href' => $this->url->link('product/latest', $url . '&limit=25')
);
$this->data['limits'][] = array(
'text' => 50,
'value' => 50,
'href' => $this->url->link('product/latest', $url . '&limit=50')
);
$this->data['limits'][] = array(
'text' => 75,
'value' => 75,
'href' => $this->url->link('product/latest', $url . '&limit=75')
);
$this->data['limits'][] = array(
'text' => 100,
'value' => 100,
'href' => $this->url->link('product/latest', $url . '&limit=100')
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}
$pagination = new Pagination();
$pagination->total = $product_total;
$pagination->page = $page;
$pagination->limit = $limit;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('product/latest', $url . '&page={page}');
$this->data['pagination'] = $pagination->render();
$this->data['sort'] = $sort;
$this->data['order'] = $order;
$this->data['limit'] = $limit;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/latest.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/latest.tpl';
} else {
$this->template = 'default/template/product/latest.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
}
?>
hello, can anybody help me..
my latest product won't show the image..
website: tulip-craft.com
please somebosy help to fix this problem..
thanks..
my latest product won't show the image..
website: tulip-craft.com
Code: Select all
<?php
$this->language->load('spicylicious_custom/spicy');
$text_wish = $this->language->get('text_wish');
$text_compare = $this->language->get('text_compare');
?>
<?php if (($setting['position'] == 'content_top') || ($setting['position'] == 'content_bottom')){ ?>
<div class="box">
<h2 class="heading-title"><span><?php echo $heading_title; ?></span></h2>
<div class="box-content">
<div class="box-product fixed">
<?php foreach ($products as $product) { ?>
<div class="prod_hold">
<?php if ($product['thumb']) { ?>
<a class="wrap_link" href="<?php echo $product['href']; ?>"><span class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></span></a>
<?php } ?>
<?php if ($product['price']) { ?>
<?php if (!$product['special']) { ?>
<div class="pricetag_small"><span class="price"><?php echo $product['price']; ?></span></div>
<?php } else { ?>
<div class="pricetag_small"><span class="old_price"><?php echo $product['price']; ?></span> <span class="new_price"><?php echo $product['special']; ?></span></div>
<?php } ?>
<?php } ?>
<div class="info">
<h3><?php echo $product['name']; ?></h3>
<p><?php echo $product['description']; ?></p>
<a class="add_to_cart_small" onclick="addToCart('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></a> <a class="wishlist_small" onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $text_wish; ?></a> <a class="compare_small" onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $text_compare; ?></a> </div>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } else { ?>
<div class="box">
<div class="box-content">
<h3 class="heading-title"><span><?php echo $heading_title; ?></span></h3>
<?php foreach ($products as $product) { ?>
<div class="product_unit">
<?php if ($product['thumb']) { ?>
<a class="image" href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a>
<?php } ?>
<span class="name"><?php echo $product['name']; ?></span>
<?php if ($product['price']) { ?>
<?php if (!$product['special']) { ?>
<span class="price"><?php echo $product['price']; ?></span>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price"><?php echo $product['special']; ?></span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<div class="clear"></div>
</div>
</div>
<?php } ?>
thanks..
All about Crochet and Knitting, a Handicraft Store -> http://tulip-craft.com
SOLVED.!!
Code: Select all
<?php foreach ($products as $product) { ?>
<div class="prod_hold">
<?php if ($product['thumb']) { ?>
<a class="wrap_link" href="<?php echo $product['href']; ?>"><span class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" />
All about Crochet and Knitting, a Handicraft Store -> http://tulip-craft.com
Hi, works fine for me, so thanks for it.
Just have a small problem, sorting by name, price etc. doesn't work for me..
Just have a small problem, sorting by name, price etc. doesn't work for me..
Code: Select all
<?php
class ControllerProductLatest extends Controller {
public function index() {
$this->language->load('product/latest');
$this->load->model('catalog/product');
$this->load->model('tool/image');
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'p.sort_order';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
/*if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
} else {
$limit = $this->config->get('config_catalog_limit');
}*/
$this->document->setTitle($this->language->get('heading_title'));
$this->document->addScript('catalog/view/javascript/jquery/jquery.total-storage.min.js');
$this->data['breadcrumbs'] = array();
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
/*if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}*/
$this->data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('product/latest', $url),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_empty'] = $this->language->get('text_empty');
$this->data['text_quantity'] = $this->language->get('text_quantity');
$this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
$this->data['text_model'] = $this->language->get('text_model');
$this->data['text_price'] = $this->language->get('text_price');
$this->data['text_tax'] = $this->language->get('text_tax');
$this->data['text_points'] = $this->language->get('text_points');
$this->data['text_compare'] = sprintf($this->language->get('text_compare'), (isset($this->session->data['compare']) ? count($this->session->data['compare']) : 0));
$this->data['text_display'] = $this->language->get('text_display');
$this->data['text_list'] = $this->language->get('text_list');
$this->data['text_grid'] = $this->language->get('text_grid');
$this->data['text_sort'] = $this->language->get('text_sort');
$this->data['text_limit'] = $this->language->get('text_limit');
$this->data['button_cart'] = $this->language->get('button_cart');
$this->data['button_wishlist'] = $this->language->get('button_wishlist');
$this->data['button_compare'] = $this->language->get('button_compare');
$this->data['compare'] = $this->url->link('product/compare');
$this->data['products'] = array();
$data = array(
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $limit,
/*'limit' => $limit*/
);
$product_total = $this->model_catalog_product->GetLatestProducts($data);
$results = $this->model_catalog_product->getLatestProducts(20);
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_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['latest']) {
$latest = $this->currency->format($this->tax->calculate($result['latest'], $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$latest = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['latest'] ? $result['latest'] : $result['price']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = (int)$result['rating'];
} else {
$rating = false;
}
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
'price' => $price,
'latest' => $latest,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url)
);
}
$url = '';
/*if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}*/
$this->data['sorts'] = array();
$this->data['sorts'][] = array(
'text' => $this->language->get('text_default'),
'value' => 'p.sort_order-ASC',
'href' => $this->url->link('product/latest', 'sort=p.sort_order&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_asc'),
'value' => 'pd.name-ASC',
'href' => $this->url->link('product/latest', 'sort=pd.name&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_desc'),
'value' => 'pd.name-DESC',
'href' => $this->url->link('product/latest', 'sort=pd.name&order=DESC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_asc'),
'value' => 'ps.price-ASC',
'href' => $this->url->link('product/latest', 'sort=ps.price&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_desc'),
'value' => 'ps.price-DESC',
'href' => $this->url->link('product/latest', 'sort=ps.price&order=DESC' . $url)
);
if ($this->config->get('config_review_status')) {
$this->data['sorts'][] = array(
'text' => $this->language->get('text_rating_desc'),
'value' => 'rating-DESC',
'href' => $this->url->link('product/latest', 'sort=rating&order=DESC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_rating_asc'),
'value' => 'rating-ASC',
'href' => $this->url->link('product/latest', 'sort=rating&order=ASC' . $url)
);
}
$this->data['sorts'][] = array(
'text' => $this->language->get('text_model_asc'),
'value' => 'p.model-ASC',
'href' => $this->url->link('product/latest', 'sort=p.model&order=ASC' . $url)
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_model_desc'),
'value' => 'p.model-DESC',
'href' => $this->url->link('product/latest', 'sort=p.model&order=DESC' . $url)
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
/*$this->data['limits'] = array();*/
/*$limits = array_unique(array($this->config->get('config_catalog_limit'), 25, 50, 75, 100));*/
/*sort($limits);*/
/*foreach($limits as $value){
$this->data['limits'][] = array(
'text' => $value,
'value' => $value,
'href' => $this->url->link('product/latest', $url . '&limit=' . $value)
);
}*/
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
/*if (isset($this->request->get['limit'])) {
$url .= '&limit=' . $this->request->get['limit'];
}*/
/*$pagination = new Pagination();
$pagination->total = $product_total;
$pagination->page = $page;
$pagination->limit = $limit;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('product/latest', $url . '&page={page}');
$this->data['pagination'] = $pagination->render();*/
$this->data['sort'] = $sort;
$this->data['order'] = $order;
/*$this->data['limit'] = $limit;*/
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/latest.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/latest.tpl';
} else {
$this->template = 'default/template/product/latest.tpl';
}
$this->children = array(
'common/column_left',
'common/column_right',
'common/content_top',
'common/content_bottom',
'common/footer',
'common/header'
);
$this->response->setOutput($this->render());
}
}
?>
I have a question. How can I know whether which product is considered as Latest Product or not? can we have a way to define them?
Fatal error: Cannot access private property Document::$title in /home4/mobileblog/public_html/catalog/controller/product/latest.php on line 6
please help me
/public_html/catalog/controller/product/latest.php
<?php
class ControllerProductLatest extends Controller {
public function index() {
$this->language->load('product/latest');
$this->document->title = $this->language->get('heading_title');
$this->document->breadcrumbs = array();
$this->document->breadcrumbs[] = array(
'href' => HTTP_SERVER . 'index.php?route=common/home',
'text' => $this->language->get('text_home'),
'separator' => FALSE
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->document->breadcrumbs[] = array(
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url,
'text' => $this->language->get('heading_title'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_sort'] = $this->language->get('text_sort');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'pd.name';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
$this->load->model('catalog/product');
$url = '';
$this->load->model('catalog/review');
$this->load->model('tool/seo_url');
$this->load->model('tool/image');
$this->data['products'] = array();
$results = $this->model_catalog_product->getLatestProducts($this->config->get('config_catalog_limit'));
foreach ($results as $result) {
if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}
$rating = $this->model_catalog_review->getAverageRating($result['product_id']);
$special = FALSE;
$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
$this->data['products'][] = array(
'name' => $result['name'],
'price' => $price,
'special' => $special,
'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id'])
);
}
if (!$this->config->get('config_customer_price')) {
$this->data['display_price'] = TRUE;
} elseif ($this->customer->isLogged()) {
$this->data['display_price'] = TRUE;
} else {
$this->data['display_price'] = FALSE;
}
$url = '';
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->data['sorts'] = array();
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_asc'),
'value' => 'pd.name',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=pd.name'
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_desc'),
'value' => 'pd.name-DESC',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=pd.name&order=DESC'
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_asc'),
'value' => 'latest-ASC',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=latest&order=ASC'
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_desc'),
'value' => 'latest-DESC',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=latest&order=DESC'
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
//$pagination = new Pagination();
//$pagination->total = $product_total;
//$pagination->page = $page;
//$pagination->limit = $this->config->get('config_catalog_limit');
//$pagination->text = $this->language->get('text_pagination');
//$pagination->url = HTTP_SERVER . 'index.php?route=product/latest' . $url . '&page={page}';
//$this->data['pagination'] = $pagination->render();
$this->data['sort'] = $sort;
$this->data['order'] = $order;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/latest.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/latest.tpl';
} else {
$this->template = 'default/template/product/latest.tpl';
}
$this->children = array(
'common/header',
'common/footer',
'common/column_left',
'common/column_right'
);
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
}
?>
please help me
/public_html/catalog/controller/product/latest.php
<?php
class ControllerProductLatest extends Controller {
public function index() {
$this->language->load('product/latest');
$this->document->title = $this->language->get('heading_title');
$this->document->breadcrumbs = array();
$this->document->breadcrumbs[] = array(
'href' => HTTP_SERVER . 'index.php?route=common/home',
'text' => $this->language->get('text_home'),
'separator' => FALSE
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->document->breadcrumbs[] = array(
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url,
'text' => $this->language->get('heading_title'),
'separator' => $this->language->get('text_separator')
);
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_sort'] = $this->language->get('text_sort');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'pd.name';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
$this->load->model('catalog/product');
$url = '';
$this->load->model('catalog/review');
$this->load->model('tool/seo_url');
$this->load->model('tool/image');
$this->data['products'] = array();
$results = $this->model_catalog_product->getLatestProducts($this->config->get('config_catalog_limit'));
foreach ($results as $result) {
if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}
$rating = $this->model_catalog_review->getAverageRating($result['product_id']);
$special = FALSE;
$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
if ($discount) {
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
if ($special) {
$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
$this->data['products'][] = array(
'name' => $result['name'],
'price' => $price,
'special' => $special,
'thumb' => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id'])
);
}
if (!$this->config->get('config_customer_price')) {
$this->data['display_price'] = TRUE;
} elseif ($this->customer->isLogged()) {
$this->data['display_price'] = TRUE;
} else {
$this->data['display_price'] = FALSE;
}
$url = '';
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$this->data['sorts'] = array();
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_asc'),
'value' => 'pd.name',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=pd.name'
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_name_desc'),
'value' => 'pd.name-DESC',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=pd.name&order=DESC'
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_asc'),
'value' => 'latest-ASC',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=latest&order=ASC'
);
$this->data['sorts'][] = array(
'text' => $this->language->get('text_price_desc'),
'value' => 'latest-DESC',
'href' => HTTP_SERVER . 'index.php?route=product/latest' . $url . '&sort=latest&order=DESC'
);
$url = '';
if (isset($this->request->get['sort'])) {
$url .= '&sort=' . $this->request->get['sort'];
}
if (isset($this->request->get['order'])) {
$url .= '&order=' . $this->request->get['order'];
}
//$pagination = new Pagination();
//$pagination->total = $product_total;
//$pagination->page = $page;
//$pagination->limit = $this->config->get('config_catalog_limit');
//$pagination->text = $this->language->get('text_pagination');
//$pagination->url = HTTP_SERVER . 'index.php?route=product/latest' . $url . '&page={page}';
//$this->data['pagination'] = $pagination->render();
$this->data['sort'] = $sort;
$this->data['order'] = $order;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/latest.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/latest.tpl';
} else {
$this->template = 'default/template/product/latest.tpl';
}
$this->children = array(
'common/header',
'common/footer',
'common/column_left',
'common/column_right'
);
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
}
?>
Well, there is NO
catalog/controller/product/latest.php File in any Default Openart Version I checked,
it must therefore be some Extension, you use. Or then a russian OCShop Version, they
have such a file in their v.1.5.6.4.1 Version at least, but this would then not be an Opencart matter...
Ernie
catalog/controller/product/latest.php File in any Default Openart Version I checked,
it must therefore be some Extension, you use. Or then a russian OCShop Version, they
have such a file in their v.1.5.6.4.1 Version at least, but this would then not be an Opencart matter...
Ernie
My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Who is online
Users browsing this forum: No registered users and 118 guests