Page 1 of 2

Category on Product Page? [SOLVED]

Posted: Fri Oct 16, 2015 4:04 am
by aljawaid
Hello

I've searched everywhere and cant find a way to put the categories a product is filed under to show on the product page in OC2.0.3.1

There is a forum topic on it with code for v1.5x but it doesn't work for v2.0.3.1

Has anybody implemented this?

Re: Category on Product Page?

Posted: Fri Oct 16, 2015 9:25 pm
by viethemes
Are you using the default theme or a custom theme?
I can make a extension on the default theme.

Re: Category on Product Page?

Posted: Sat Oct 17, 2015 12:14 am
by aljawaid
hello thanks for your message.

I wasn't looking for a paid extension as such though.... but if I know the code to check and replace I would learn more. I'm learning about vqmod which is cool but the code to find to replace isn't so easy always lol.

I'm confused why categories, just like other elements don't show in the core default templates as it is.

I'm on a default template.

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 5:01 am
by aljawaid
Does anyone have any input on this?

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 4:13 pm
by uksitebuilder
Please link the 1.5.x forum topic

The code will be very similar I would think, maybe just need a slight tweak

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 6:21 pm
by aljawaid

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 6:44 pm
by uksitebuilder
The extension linked to on that post cannot be found

Do you have it ?

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 6:49 pm
by aljawaid
Hello

No but the link within that post may help. It's a vqmod guide but obviously doesnt work for 2.0.3.1

http://forum.opencart.com/viewtopic.php?f=131&t=109349

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 7:35 pm
by uksitebuilder
Here you go for 2.0.3.1 (not tested other versions)

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 8:11 pm
by aljawaid
wow, amazing and fast as always...thanks alot honestly.

Quick one though, will this show if a product is assigned to multiple categories also?

Will check it out when i get home

Re: Category on Product Page?

Posted: Sun Oct 18, 2015 8:29 pm
by uksitebuilder
Will list all linked categories

Re: Category on Product Page? [SOLVED]

Posted: Sun Oct 18, 2015 9:29 pm
by aljawaid
it works, I tweaked it for the position on the page but it works fantastic.

Thank you once again. I just dont understand why this kind of stuff is not part of the core but oh well, that's another story lol

Re: Category on Product Page? [SOLVED]

Posted: Thu Feb 18, 2016 1:58 am
by teclive
Could this work for 2.1.0.1?

Re: Category on Product Page? [SOLVED]

Posted: Wed Sep 28, 2016 9:17 pm
by dharam81
This seems not working on 2.3.0.2 version

any update please?

Re: Category on Product Page? [SOLVED]

Posted: Thu Sep 29, 2016 7:25 am
by IP_CAM
I reworked some potentially 'problemsome' Anchor-Tags/Sections, and it works well in my OC v.2.2
Ernie

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Show Linked Categories on Product page</id>
<version>1</version>
<vqmver>2.5.1</vqmver>
<author>http://www.opencart-extensions.co.uk</author>

<file name="catalog/controller/product/product.php">
<operation error="log">
<search position="after" index="1"><![CDATA[$product_info = $this->model_catalog_product->getProduct($product_id);]]></search>
<add><![CDATA[
	$data['text_linked_categories'] = $this->language->get('text_linked_categories');
	$query_linked_categories = $this->model_catalog_product->getCategories($product_id);
	$linked_categories = array();
	foreach( $query_linked_categories as $linked_category_data ) {
	$linked_category = $this->model_catalog_category->getCategory($linked_category_data['category_id']);
	$linked_category_info['id'] = $linked_category_data['category_id'];
	$linked_category_info['href'] = $this->url->link('product/category', 'path=' . $linked_category_data['category_id']);
	$linked_category_info['name'] = $linked_category['name'];
	$linked_categories[] = $linked_category_info;
	}
]]></add>
</operation>

<operation error="log">
<search position="before"><![CDATA[$data['manufacturer'] = $product_info['manufacturer'];]]></search>
<add><![CDATA[
	$data['linked_categories'] = $linked_categories;
]]></add>
</operation>
</file>

<file name="catalog/language/*/product/product.php">
<operation error="log">
<search position="before"><![CDATA[$_['text_manufacturer']]]></search>
<add><![CDATA[
	$_['text_linked_categories']        = 'Categories:';
]]></add>
</operation>
</file>

<file name="catalog/view/theme/*/template/product/product.tpl">
<operation error="log">
<search position="before"><![CDATA[<li><?php echo $text_model; ?> <?php echo $model; ?></li>]]></search>
<add><![CDATA[
	<?php if( $linked_categories ){ ?>
	<li><?php echo $text_linked_categories; ?> 
	<?php foreach( $linked_categories as $linked_category ){ ?>
	<a href="<?php echo $linked_category['href']; ?>"><?php echo $linked_category['name']; ?></a>&nbsp;
	<?php } ?>
	</li>
	<?php } ?>
]]></add>
</operation>
</file>
</modification>
---
to be seen here momentarely (only, because I use another Mod for this! :D ):
http://www.bigmax.ch/oc22/index.php?rou ... duct_id=40
---

Re: Category on Product Page? [SOLVED]

Posted: Thu Sep 29, 2016 7:37 am
by IP_CAM
dharam81 wrote:This seems not working on 2.3.0.2 version, any update please?
Usually, those, who cannot live, without belonging to the TOP, have to pay,
to keep their Frontrunner-Status ;D
Ernie

Re: Category on Product Page? [SOLVED]

Posted: Thu Sep 29, 2016 8:49 pm
by dharam81
Hi Ernie,

this one worked for me thanks you are champion.

Cheers

Re: Category on Product Page? [SOLVED]

Posted: Sun May 14, 2017 1:35 pm
by u22im
it's work for 2.0.3.1

I uploaded .xml >> vqmod
and then I must add code in .xml file to source ( find file follow xml for custom theme )

And it's work!

Thanks

Re: Category on Product Page? [SOLVED]

Posted: Thu Sep 13, 2018 3:13 pm
by jfn99
How can I do this on opencart version 3? anyone?
thanks

Re: Category on Product Page?OC version 3.0.x

Posted: Thu Sep 13, 2018 6:46 pm
by kestas
jfn99 wrote:
Thu Sep 13, 2018 3:13 pm
How can I do this on opencart version 3? anyone?
thanks
download and enjoy :) there I have rewrote code which was placed by Ernie ;)

Cheers