Categories (name and link) in Specials Module
Posted: Fri May 15, 2015 10:24 am
Hello. Can someone help me making simple module to show categories (name and link) under product name on homepage in specials module? I'm working on localhost for now on default open theme (OpenCart 2.0.2.0). I found working module that shows exactly what i want to achieve but in product page (not in homepage -> special module).
It's probalby very easy to do but i cant make it working.
Working module on product page:
Additional links:
http://forum.opencart.com/viewtopic.php?f=131&t=109349
http://forum.opencart.com/viewtopic.php?f=190&t=142671
It's probalby very easy to do but i cant make it working.
Working module on product page:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Show categories(name and link) on product page</id>
<version>1</version>
<vqmver>2.3.2</vqmver>
<author>Andrei Bogdan (andrei.opencart@yahoo.com)</author>
<file name="catalog/controller/product/product.php">
<operation>
<search position="after"><![CDATA[$product_info = $this->model_catalog_product->getProduct($product_id);]]></search>
<add><![CDATA[
$data['text_category'] = $this->language->get('text_category');
$querycats = $this->model_catalog_product->getCategories($product_id);
$categories = array();
foreach( $querycats as $item ) {
$categ = $this->model_catalog_category->getCategory($item['category_id']);
$catinfo['id'] = $item['category_id'];
$catinfo['href'] = $this->url->link('product/category', 'path=' . $item['category_id']);
$catinfo['name'] = $categ['name'];
$categories[] = $catinfo;
}
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[$data['manufacturer'] = $product_info['manufacturer'];]]></search>
<add><![CDATA[
$data['categories'] = $categories;
]]></add>
</operation>
</file>
<file name="catalog/language/english/product/product.php">
<operation>
<search position="after"><![CDATA[$_['text_manufacturer'] = 'Brand:';]]></search>
<add><![CDATA[
$_['text_category'] = 'Categories:';
]]></add>
</operation>
</file>
<file name="catalog/view/theme/default/template/product/product.tpl">
<operation>
<search position="after" offset="1"><![CDATA[<span><?php echo $text_manufacturer; ?></span> <a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a><br />]]></search>
<add><![CDATA[
<?php if( $categories ): ?>
<span><?php echo $text_category; ?></span>
<?php foreach( $categories as $category ): ?>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php endforeach; ?>
<br />
<?php endif; ?>
]]></add>
</operation>
</file>
</modification>
http://forum.opencart.com/viewtopic.php?f=131&t=109349
http://forum.opencart.com/viewtopic.php?f=190&t=142671