Hi.
I want to show a list of products of the same category below a detail product.
some like this:
{Products lang="es_ES" action="default" category="$category->name" sortby="random" pagelimit="2"}
But i get "Catchable fatal error: Object of class stdClass could not be converted to string in /home/sanatori/electrodomesticos.com.py/tmp/templates_c/Products^%%DE^DE2^DE2A799D%%module_db_tpl%3AProducts%3Bdetail_Sample.php on line 106"
I try some variants but I cant get solution.
Anyone interested?
Thanks.
products module (get category )
Re: products module (get category )
Please try:
It seems that removing double quotes helped some people. However, I had same problem and i wasn't able to resolve it. 
Code: Select all
{Products lang="es_ES" action="default" category=$category->name sortby="random" pagelimit="2"}

Re: products module (get category )
I've been working on an e-commerce site and I wanted something similar. I had to tweak the code above to get it to do what I want, but the concept is the same.
On each detail page, I wanted at the bottom a short list of similar items -- items in the same category.
Because my templates are convoluted, I created a new summary template that just contains a loop of the category code. Adjust the style hooks to suit your own design:
Now that I know CMSMS will spit out the category items the way I want, I added this to the bottom of my detail page template:
The page limit controls the NUMBER of items displayed, and of course, the call to the summarytemplate is to the template I created above.
HTH someone else.
You can see it in action here:
http://honfish.pixelita.net/store/16/Capelin-Caviar/
Login credentials are:
USERID: Client
PWORD: letmein
Oh, and MUTE THE SOUND. I cannot convince this client not to play videos on pageload...
On each detail page, I wanted at the bottom a short list of similar items -- items in the same category.
Because my templates are convoluted, I created a new summary template that just contains a loop of the category code. Adjust the style hooks to suit your own design:
Code: Select all
{if isset($catformstart)}
{$catformstart}
{$catdropdown}{$catbutton}
{$catformend}
{/if}
<!-- Product Display -->
{foreach from=$items item=entry}
<div class="store-summary-items">
{if count($entry->fields)}
{foreach from=$entry->fields key='name' item='field'}
{if $field->name == 'Image'}
<div class="summary-product-link">
<a href="{$entry->detail_url}" class="item-link">{$entry->product_name}</a> ({$currency_symbol}{$entry->price})</div>
<a href="{$entry->detail_url}" class="item-link"><img class="item-image" src="{$entry->file_location}/{$field->value}" width="125" height="144" alt="{$field->value}"/></a>
{/if}
{/foreach}
{/if}
</div><!-- /store-summary-items -->
{/foreach}
Code: Select all
{Products action="default" category=$category->name sortby="random" pagelimit="4" summarytemplate="HFC-Summary-Short"}</
HTH someone else.
You can see it in action here:
http://honfish.pixelita.net/store/16/Capelin-Caviar/
Login credentials are:
USERID: Client
PWORD: letmein
Oh, and MUTE THE SOUND. I cannot convince this client not to play videos on pageload...

Submit your site to the We Love CMSMS showcase
-
- Forum Members
- Posts: 89
- Joined: Thu Aug 21, 2008 11:47 am
Re: products module (get category )
I needed something similar too and came up with the same solution as pixelita but found as I'm sure they have that the same product would appear in the 'Other you may like' list as you were looking at.
Not the worst thing that could happen but I wanted to stop this happening just because it annoyed me.
This is the Products Manager summary template I created:
As you'll notice I have a call to a variable called $bike_id. This is setup to get the ID of the current product you are looking at and therefore not show that product in the 'You might like list'.
I then added a capture call to the detail template to assign the current ID to the $bike_id variable like:
I also found an anomolie and I did work out why, but have since forgotten. I wanted to show 3 products in the 'You may also like' list so set the product manager call to a pagelimit of 3 as you would expect. Unfortunately it appears as though if the call pulls in three and one of those matches the ID you don't want it only shows 2. So to get round this I set the pagelimit to one more than I actually wanted, in this case 4 and then just hid the extra one if it appeared using CSS.
Hope this helps.
Not the worst thing that could happen but I wanted to stop this happening just because it annoyed me.
This is the Products Manager summary template I created:
Code: Select all
<div id="bikeSelector">
{foreach from=$items item=entry name=bikelist}
{if $smarty.foreach.bikelist.iteration is div by 4 && $entry->id != $bike_id}
{capture assign="bikeURL"}{$entry->detail_url}{/capture}
{assign var=foo value="/"|explode:$bikeURL}
<div class="bikeCol last {$entry->id}">
{foreach from=$entry->fields key='name' item='field'}
{if $field->type == 'image' && $name =='product_image'}
<div class="bikeImg">
<a href="{$foo[0]}//{$foo[1]}{$foo[2]}/{$foo[3]}/{$foo[4]}/{$page_id}/{$foo[5]}"><img src="{$entry->file_location}/{$field->value}" alt="{$field->value}" width="222" height="127" /></a>
</div>
{/if}
{/foreach}
<div class="bikeTitle">
<h2><a href="{$foo[0]}//{$foo[1]}{$foo[2]}/{$foo[3]}/{$foo[4]}/{$page_id}/{$foo[5]}">{$entry->product_name}</a></h2>
</div>
<div class="bikePrice">
<h3>from £{$entry->price|number_format:","}</h3>
</div>
<div class="bikeDesc">
{$entry->details}
</div>
<div class="bikeLink">
<a href="{$foo[0]}//{$foo[1]}{$foo[2]}/{$foo[3]}/{$foo[4]}/{$page_id}/{$foo[5]}">full spec »</a>
</div>
</div>
<div class="clear"></div>
{elseif $entry->id != $bike_id}
{capture assign="bikeURL"}{$entry->detail_url}{/capture}
{assign var=foo value="/"|explode:$bikeURL}
<div class="bikeCol {$entry->id}">
{foreach from=$entry->fields key='name' item='field'}
{if $field->type == 'image' && $name =='product_image'}
<div class="bikeImg">
<a href="{$foo[0]}//{$foo[1]}{$foo[2]}/{$foo[3]}/{$foo[4]}/{$page_id}/{$foo[5]}"><img src="{$entry->file_location}/{$field->value}" alt="{$field->value}" width="222" height="127" /></a>
</div>
{/if}
{/foreach}
<div class="bikeTitle">
<h2><a href="{$foo[0]}//{$foo[1]}{$foo[2]}/{$foo[3]}/{$foo[4]}/{$page_id}/{$foo[5]}">{$entry->product_name}</a></h2>
</div>
<div class="bikePrice">
<h3>from £{$entry->price|number_format:","}</h3>
</div>
<div class="bikeDesc">
{$entry->details}
</div>
<div class="bikeLink">
<a href="{$foo[0]}//{$foo[1]}{$foo[2]}/{$foo[3]}/{$foo[4]}/{$page_id}/{$foo[5]}">full spec »</a>
</div>
</div>
{/if}
{/foreach}
</div>
I then added a capture call to the detail template to assign the current ID to the $bike_id variable like:
Code: Select all
{capture assign='bike_id'}{$entry->id}{/capture}
Hope this helps.