Post by vimal » Sun Nov 13, 2011 4:57 am

Hi

I want to display short description for products in the modules like featured, bestseller etc. How can I add it? I tried to fiddle around with the controller and tpl files but got a lot of undefined errors. I also tried to compare it with the category page to see if I could get some clues but couldn't solve it. I am not really a php programmer and my knowledge in that is really limited.

Could someone please help me? I am using OC1.5.1.3

Thanks!
Vimal.
Last edited by vimal on Mon Nov 14, 2011 2:02 am, edited 1 time in total.

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by wernerrenrew » Sun Nov 13, 2011 7:19 am

Hi,

Open catalog/controler/module/special.php
on line 50 you will see an array replace it with this

Code: Select all

$this->data['products'][] = array(
				'product_id' => $result['product_id'],
				'thumb'   	 => $image,
				'name'    	 => $result['name'],
                                'description'    => $result['description'],
				'price'   	 => $price,
				'special' 	 => $special,
				'rating'     => $rating,
				'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
				'href'    	 => $this->url->link('product/product', 'product_id=' . $result['product_id']),
			);
now open catalog/view/theme/your-theme/template/module/special.tpl
look for this

Code: Select all

<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
          <?php } ?>
        </div>
right after this you put this

Code: Select all

<div><?php echo "<p>".mb_substr(strip_tags(html_entity_decode($product['description'])), 0, 150)."...</p>"; ?></div>
BTW if you follow the demo link below i made a live example you will also see my free random specials module in action.

Did this solve your problem add [SOLVED] to the title of this topic.

Regards Werner

User avatar
Active Member

Posts

Joined
Thu Oct 27, 2011 9:48 pm
Location - Netherlands

Post by vimal » Mon Nov 14, 2011 1:38 am

Hi.
I got an error message saying as below.

Code: Select all

Notice: Undefined variable: result in C:\xampp\htdocs\oc1511\catalog\controller\module\featured.php on line 50Notice: Undefined variable: result in C:\xampp\htdocs\oc1511\catalog\controller\module\featured.php on line 50Notice: Undefined variable: result in C:\xampp\htdocs\oc1511\catalog\controller\module\featured.php on line 50Notice: Undefined variable: result in C:\xampp\htdocs\oc1511\catalog\controller\module\featured.php on line 50
Line 50 is

Code: Select all

'description'    => $result['description'],

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by vimal » Mon Nov 14, 2011 1:55 am

And the description only shows ".." excluding the quotation mark.

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by vimal » Mon Nov 14, 2011 2:02 am

Solved it. The array looks as below.

Code: Select all

$this->data['products'][] = array(
					'product_id' => $product_info['product_id'],
					'thumb'   	 => $image,
					'name'    	 => $product_info['name'],
					'price'   	 => $price,
					'description' => substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
					'special' 	 => $special,
					'rating'     => $rating,
					'reviews'    => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']),
					'href'    	 => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
				);
And in the template file.

Code: Select all

<?php echo $product['description']; ?>

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by vimal » Mon Nov 14, 2011 2:15 am

Hi All,

Just realised that the code above for the array works for featured module only. For other modules,

Replace the line

Code: Select all

'description' => substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
with

Code: Select all

'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
difference being $result instead of $product_info

You can check in the array what is being used and use the same one.

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden

Post by wernerrenrew » Mon Nov 14, 2011 2:30 am

Hi,

My code is solid but you are right that you would need a little ajustment for other modules.

Open catalog/controler/module/special.php
on line 50 you will see an array replace it with this
Your welcome

Regards Werner

User avatar
Active Member

Posts

Joined
Thu Oct 27, 2011 9:48 pm
Location - Netherlands

Post by vimal » Mon Nov 14, 2011 3:03 am

Thanks for your help. Your solution gave me a direction to start hacking :-)

www.beeshop.se
Starta webbshop, Starta e-butik, Starta e-handel


Active Member

Posts

Joined
Wed Aug 26, 2009 8:54 am
Location - Sweden
Who is online

Users browsing this forum: No registered users and 14 guests