nVelocity question

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

nVelocity question

Post by heinscott » Mon Jan 05, 2009 3:40 pm

I am trying to use the RelatedProducts collection on my products page in order to implement suggested selling (when we would rather have a customer order something other than what they are currently on (for shipping reasons)). My question is this: Can I use only the first item in the collection rather than loop through each of them? Here's what I have tried...

$Product.RelatedProducts[0].ChildProduct.Name

with no luck. If, however, I use...

#foreach ($relatedproduct in $Product.RelatedProducts)
$relatedproduct.ChildProduct.Name
#end

...I get the desired outcome. The problem, however, is that I may have more than one product, and eventually I am going to be including table elements that will be all screwed up if the loop executes more than one time. I have tried various forms of the variable with brackets with no luck (ie, ${{Product.RelatedProducts[0]}.ChildProduct.Name})

I know I could complete this (and probably will have to eventually) with a conlib control, but, I wanted to figure out why specifying the specific item with brackets causes the nVelocity to stop working.

Any help would be appreciated.

Scott
Scott

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: nVelocity question

Post by mazhar » Tue Jan 06, 2009 7:05 am

Try following syntax

Code: Select all

$Product.RelatedProducts.get_item(0).ChildProduct.Name

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: nVelocity question

Post by heinscott » Tue Jan 06, 2009 8:27 am

Thanks Mazhar!
I had a feeling you'd be able to help me.

Scott

Post Reply