Wednesday, July 6, 2011

Prestashop as Bookstore Part 4 - Details in product lists

I have done several modifications to make PrestaShop usable as a bookstore and I will try to sum it up in a few blog posts.

(I don't really have time for this, but a new post is overdue ++)

To put tags in the product list:
In classes/product.php, find eg

$row['features'] = Product::getFrontFeaturesStatic((int)$id_lang, $row['id_product']);

and add the line

$row['tags'] = Tag::getProductTags($row['id_product']);

In eg themes/yourtheme/product-list.tpl, find the line


and add

{if $product.location}
{if $product.tags}

{if $lang_iso == sv} {assign var='lng' value=4}{else} {assign var='lng' value=1} {/if}
{assign var='tag1' value=$product.tags[$lng]}
{assign var='delimiter' value=''}
{l s='Authors'}:
{foreach from=$tag1 item=tag}{$delimiter} {$tag|escape:'htmlall':'UTF-8'}{assign var='delimiter' value=','}{/foreach}

To put features at the same place
In eg themes/yourtheme/product-list.tpl, at the same place as for the tags, add

{if $product.features}

{assign var='go' value='0'}
{foreach from=$product.features item=feature}
{foreach from=$feature item=rank}
{if $go}Rank: {$rank}<br />{/if}
{if $rank == '40.Suggested rank'}{assign var='go' value='1'}
{else} {assign var='go' value='0'}

Short explanation of the code:
I use tags for authors and location to pin a item as a book, other parts of the logic may or may not be of use for you, the delimeter jazz is so that one tag appears as "foo" and tho tags as "foo, bar", ie comma separated.
The features array looks like this
Length, 10 cm, height, 2 cm, weight, 2 kg...
So I search for "Suggested rank" and print the following value. I only use one feature, but there is nothing stopping you from using more.

Edit: Forgot to add a picture of how it looks


  1. I own an Ecommerce site and for me its easy to market my products because of the cool features of Prestashop Themes which isn't available on other kind of shopping cart softwares.