Jump to content

Add image to feature in layered navigation


Recommended Posts

I would like to be able to sort my product on color.

BUT... I do not want this color as an attribute. I want it as a feature.


I am using attribute wizard pro (great module) and if I add the sort on color option as an attribute it also shows when looking at a product. And I only want it as a sort option.


But, it would be nice to be able to sort on an image instead of only text.

Like when you sort on a color attribute:



I have tried the following (from this post: http://www.prestashop.com/forums/topic/298061-how-to-add-hyperlink-and-images-to-features/?hl=%2Bfeatures ) , this works in the datasheet underneath the product:


But I would also like to add this to the layered navigation. Anyone any ideas?


If so, do this: (Sample code from PrestaShop

in file: /classes/FeatureValue.php, change this: (change red code)  (Back up the file first, just in case...)

public static $definition = array(
  'table' => 'feature_value',
  'primary' => 'id_feature_value',
  'multilang' => true,
  'fields' => array(
  'id_feature' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
  'custom' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
  // Lang fields
  'value' => array('type' => self::TYPE_NOTHING, 'lang' => true, 'validate' => 'isAnything', 'required'
  => true, 'size' => 255),
and save file.
Then edit file: /themes/<your theme folder>/product.tpl  (backup file...)
and find the following code: (around line 500, search for 'feature' using Ctrl-F): Remove red code:
{if isset($features) && $features}
<!-- product's features -->
<ul id="idTab2" class="bullet">
{foreach from=$features item=feature}
            {if isset($feature.value)}
   <li><span>{$feature.name|escape:'htmlall':'UTF-8'}</span> {$feature.value|escape:'htmlall':'UTF-8'}</li>


and save. then edit/create your features and add as feature value something like this:


<img src="http://fff.re/d5aH" width=40 height=40><a href="http://fff.re/8T1G">Search</a>


Where <img> of course gives the image, and <a> gives the link


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...