Jump to content

Add thumbnails to Popular Products box

Mike MacKechnie

Recommended Posts

Does anybody know how to add thumbnail images to the Popular Products box in CCV6?


I'm using the crosshatch skin with a few css tweaks but pretty much straight out of the box.


This is my source for crosshatch/templates/box.popular.php:


<div class="box">
{foreach from=$POPULAR item=product}
<p class="image">
<a href="{$product.url}" title="{$product.name}">
<img src="{$product.image_small}"/>
<li><a href="{$product.url}" title="{$product.name}">{$product.name}</a></li>
the "{$product.image_small}" placeholder is not working. I tried "{$product.image}" as well but same result. {$product.url} and {$product.name} work fine so I'm guessing that there's somewhere where I've got to get Smarty to load the $product.image placeholder. I'm a newbie to Smarty so any help would be appreciated.
Link to comment
Share on other sites

At the end of box.popular.php, add {debug}. Be sure to have your browser allow popups.


You will be given a popup with all the variables that this template has available. Under $product, you will see that the array elements do not include an image.


In the file /classes/gui.class.php, find private function _displayPopularProducts(). In this function you can hard code a statement that will get links to one or all image variants, or we can use a hook.


For a hard coded statement, try:

$product['sale_price'] = ($sale) ? $GLOBALS['tax']->priceFormat($product['sale_price']) : null;
Add after:
$product['image_url'] = $this->getProductImage($product['product_id']);

Then, the template code now has $product.image_url available.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...