Page 1 of 1

Product model instead of name in category product grid

Posted: Fri Nov 04, 2016 1:27 am
by joss
Hello to all,
I welcome the community of Opencart which I just started learning for the specific e-commerce platform recently.

Using VQMOD I have successfully inserted the product model instead of name in product grid.
Though, after using taxonomy, navigation filters or pagination the grid brings back the product name.

Most probable is that somewhere in javascript code requests again the product name. Does anyone know at which part of the code is that?

Thanks in advance..
Opencart 2.1.0.2 & Journal Theme

The vqmod contents are the following.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>

<modification>
	<id><![CDATA[Product Model in Category]]></id>
	<version><![CDATA[1.0]]></version>
	<vqmver><![CDATA[2.1x]]></vqmver>
	<author><![CDATA[Author]]></author>

<file name="/catalog/view/theme/journal2/template/product/category.tpl">
		<operation>
			<search position="replace"><![CDATA[<h4 class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></h4>]]></search> 
			<add><![CDATA[<h4 class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['model']; ?></a></h4>]]>
			</add>
		</operation>
</file>	

</modification>

Re: Product model instead of name in category product grid

Posted: Fri Nov 04, 2016 5:52 pm
by knowband.plugins
In the same file, you might need to modify a javascript function display(view) {... }

Re: Product model instead of name in category product grid

Posted: Fri Nov 04, 2016 11:49 pm
by joss
Yes but which function would be?
If you direct me to the file at least I could search which part of the code to change.

I'm new to opencart and still trying to find how this whole system works..
Thanks
knowband.plugins wrote:In the same file, you might need to modify a javascript function display(view) {... }

Re: Product model instead of name in category product grid

Posted: Sat Nov 05, 2016 1:26 am
by IP_CAM
There is no Script involved with this, it just misses the Model Declaration in the Array! ::)
Ernie

catalog/controller/product/category.php
OLD:

Code: Select all

$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, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
					'price'       => $price,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
				);
NEW:

Code: Select all

$data['products'][] = array(
					'product_id'  => $result['product_id'],
					'thumb'       => $image,
					'name'        => $result['name'],
					'model'        => $result['model'],
					'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
					'price'       => $price,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
				);
/theme/template/product/category.tpl (Basic Output Code)

Code: Select all

<div>Model: <?php echo $product['model']; ?></div>
The revised VqMod would therefore look like this: (tested with OC v.2.2.x Default Theme)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<modification>
<id><![CDATA[Product Model in Category]]></id>
<version><![CDATA[1.0]]></version>
<vqmver><![CDATA[2.5.x]]></vqmver>
<author><![CDATA[Ernie - IP_CAM]]></author>
       
    <file name="catalog/controller/product/category.php">
    <operation error="log">
    <search position="after"><![CDATA[$result['name'],]]></search>
    <add><![CDATA[
       'model'        => $result['model'],
    ]]></add>
    </operation>
    </file> 
       
    <file name="catalog/view/theme/*/template/product/category.tpl">
    <operation error="log">
    <search position="after"><![CDATA[<div class="caption">]]></search>
    <add><![CDATA[
       <div>Model: <?php echo $product['model']; ?></div>
    ]]></add>
    </operation>
    </file>   
    </modification>
---
PS: And here is another VqMod, to display the Manufacturer the same way in the Category Section:
viewtopic.php?f=182&t=170072&p=645254#p645254
---

Re: Product model instead of name in category product grid

Posted: Mon Nov 07, 2016 10:07 pm
by joss
Thanks for your answer but unfortunately this does not work,
the "Model" declaration was already in category.php, otherwise it wouldn't work in the first place.

It does not work in javascript reload, when we select pagination or filters.
IP_CAM wrote:There is no Script involved with this, it just misses the Model Declaration in the Array! ::)
Ernie

catalog/controller/product/category.php
OLD:

Code: Select all

$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, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
					'price'       => $price,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
				);
NEW:

Code: Select all

$data['products'][] = array(
					'product_id'  => $result['product_id'],
					'thumb'       => $image,
					'name'        => $result['name'],
					'model'        => $result['model'],
					'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
					'price'       => $price,
					'special'     => $special,
					'tax'         => $tax,
					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
					'rating'      => $result['rating'],
					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
				);
/theme/template/product/category.tpl (Basic Output Code)

Code: Select all

<div>Model: <?php echo $product['model']; ?></div>
The revised VqMod would therefore look like this: (untested, I use no Journal Themes)

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<modification>
<id><![CDATA[Product Model in Category]]></id>
<version><![CDATA[1.0]]></version>
<vqmver><![CDATA[2.1x]]></vqmver>
<author><![CDATA[Author]]></author>
    
<file name="catalog/controller/product/category.php">
<operation error="log">
<search position="after"><![CDATA[$result['name'],]]></search>
<add><![CDATA[
	'model'        => $result['model'],
]]></add>
</operation>
</file>  
	
<file name="catalog/view/theme/journal2/template/product/category.tpl">
<operation error="log">
<search position="replace"><![CDATA[<h4 class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></h4>]]></search>
<add><![CDATA[
	<h4 class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['model']; ?></a></h4>
]]></add>
</operation>
</file>   
</modification>
---
PS: And here is another VqMod, to display the Manufacturer the same way in the Category Section:
viewtopic.php?f=182&t=170072&p=645254#p645254
---

Re: Product model instead of name in category product grid

Posted: Tue Nov 08, 2016 2:27 am
by IP_CAM
Sorry, but this has absolutely nothing to do with Pagination or Javascript
if you have placed the Model Line just below, like here,in the category.tpl file,
then, it will function, I am sure:

Code: Select all

<div class="caption">
<div>Model: <?php echo $product['model']; ?></div>
Ernie

PS. I updated the VqMod, placed further above, to make it work with a Default Themed OC v.2.2.x!
The latest Category Image further above reflects the result!
It's driven by an OC v.2.2.6.4 CC - Multi Vendor Marketplace, technically equal or > to default OC v.2.2.x, I assume:
https://github.com/Evgenii-v/clerkscart

Test Site:
http://www.jti.li/shop/index.php?route= ... 20&limit=5

Re: Product model instead of name in category product grid

Posted: Wed Nov 09, 2016 8:53 pm
by joss
ok, thank you for all your replies.

The problem seems to be inside themes code. I'm going to ask theme creator.

Re: Product model instead of name in category product grid

Posted: Tue Jan 10, 2017 1:07 pm
by kinuschan
joss wrote:ok, thank you for all your replies.

The problem seems to be inside themes code. I'm going to ask theme creator.
Hi Joss,
Did you solve this issue? i would like to know how to fix and show the product model in category product grid too.
thanks.

Re: Product model instead of name in category product grid

Posted: Wed Jan 11, 2017 11:24 am
by IP_CAM
I just created another OcMod, by use of OC v.2.2.x Software, and explained some more details on this:
viewtopic.php?f=190&t=149352&p=653015#p653015
Ernie