I've built two opencart sites where this feature has been requested so I'm assuming other people will need it.
In
/catalog/controller/home.php
change :
Code: Select all
$product_data = array();
//See: http://forum.opencart.com/index.php?topic=100.0
$results = $database->getRows("select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '" . (int)$language->getId() . "' and p.date_available < now() and p.status = '1' order by p.date_added desc limit 6");
foreach ($results as $result) {
$product_data[] = array(
'name' => $result['name'],
'href' => $url->href('product', FALSE, array('product_id' => $result['product_id'])),
'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $config->get('config_tax')))
);
}
$view->set('products', $product_data);
Code: Select all
$category_data = array();
$results = $database->getRows("select * from category c left join category_description cd on (c.category_id = cd.category_id) left join image i on (c.image_id = i.image_id) where c.parent_id = '0' and cd.language_id = '" . (int)$language->getId() . "' order by sort_order");
foreach ($results as $result) {
$category_data[] = array(
'name' => $result['name'],
'href' => $url->href('category', FALSE, array('path' => $result['category_id'])),
'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height'))
);
}
$view->set('categories', $category_data);
and in /catalog/template/[template name]/content/home.tpl
change:
Code: Select all
<div class="heading"><?php echo $text_latest; ?></div>
<?php foreach ($products as $product) { ?>
<div class="products"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>"></a><br><b><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></b><br><?php echo $product['price']; ?></div>
<?php } ?>
to:
Code: Select all
<?php if ($categories) { ?>
<?php foreach ($categories as $category) { ?>
<div class="categories"><a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" title="<?php echo $category['name']; ?>" alt="<?php echo $category['name']; ?>" /></a><br />
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></div>
<?php } ?>
<?php } ?>
any problems give me a PM.
Thanks