Hi!
How do you get the name of the default unit for a product in Ecom? The default unit for my products is 'ML' and I want to display that.
Is there a way to do this?
Developer forum
E-mail notifications
Print name of unit
Per Ljung
Posted on 29/06/2011 09:51:11
Replies
Vladimir
Posted on 30/06/2011 06:43:46
Hi Per!
<!--@LoopStart(Units)-->
<!--@If(Ecom:VariantOption.Selected=='SELECTED')-->
<br /><br />
<h2 class="h2">Default Unit</h2>
<!--@Ecom:VariantOption.ID-->
<!--@Ecom:VariantOption.Name-->
<!--@Ecom:VariantOption.Selected-->
<!--@EndIf-->
<!--@LoopEnd(Units)-->
Best regards,
Vladimir
<!--@LoopStart(Units)-->
<!--@If(Ecom:VariantOption.Selected=='SELECTED')-->
<br /><br />
<h2 class="h2">Default Unit</h2>
<!--@Ecom:VariantOption.ID-->
<!--@Ecom:VariantOption.Name-->
<!--@Ecom:VariantOption.Selected-->
<!--@EndIf-->
<!--@LoopEnd(Units)-->
Best regards,
Vladimir
Per Ljung
Posted on 08/09/2011 14:54:57
But how do you do this in xslt?
Best regards,
Per
Per Ljung
Posted on 08/09/2011 15:21:04
Hi!
Your code does not work. The unit of a product is there when you look on the product card and choose Store/Warehouse, but nothing is printed when I run this loop.
Do I have to make a setting or something?
Best regards,
Per
Morten Bengtson
Posted on 08/09/2011 16:03:14
Things to check:
If all of the above is done and it still doesn't work, the problem must be your template.
/Morten
- Is the unit available in the current language? (management center > ... > product units)
- Is a default unit selected on the product (dropdown)? (edit product > stock)
- Is the unit active on the product (checkbox)? (edit product > stock)
If all of the above is done and it still doesn't work, the problem must be your template.
/Morten
Per Ljung
Posted on 09/09/2011 08:14:32
Hi!
Question 1: yes
Question 2: There is nothing to select when you look in product -> stock, just a list with the columns "Unit", "Stock", "Weight" and "Size".
Question 3: There is nothing to activate, no checkbox.
Best regards,
Per
Nicolai Høeg Pedersen
Posted on 09/09/2011 09:10:58
Hi Per
I think it would help if we could get a url so we can see your setup.
I think it would help if we could get a url so we can see your setup.
Per Ljung
Posted on 09/09/2011 11:07:38
I just emailed you the url.
Nicolai Høeg Pedersen
Posted on 12/09/2011 10:58:02
I've asked someone have a look.
Vladimir
Posted on 13/09/2011 04:46:02
Hi Per!
You really don't have section 'unit' on the stock tab!O_O
As I understand, this error is due to the fact that in the table 'EcomVariantsOptions' you have the unit 'tum' with id = "
Please correct id for this unit.
Best regards,
Vladimir
You really don't have section 'unit' on the stock tab!O_O
As I understand, this error is due to the fact that in the table 'EcomVariantsOptions' you have the unit 'tum' with id = "
Please correct id for this unit.
Best regards,
Vladimir
Per Ljung
Posted on 14/09/2011 16:30:37
Hi!
Now it's correct.
But nothings is printed when I run this:
<xsl:for-each select="loop[@name='Units']/item"> <xsl:value-of select="Ecom.VariantOption.Name" disable-output-escaping="yes" /> </xsl:for-each>
It doesn't go through the loop at all.
Best regards,
Per
Per Ljung
Posted on 19/09/2011 08:35:58
Is it possible to get any help on this?
Best regards,
Per
Vladimir
Posted on 20/09/2011 03:40:34
Hi Per!
Do you add Units in availableloops variable?:
If yes, show me please your template)
Best regards,
Vladimir
Do you add Units in availableloops variable?:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" omit-xml-declaration="yes" indent="yes" encoding="utf-8"/> <xsl:param name="html-content-type"/> <xsl:variable name="availableloops" select="Units" />
Best regards,
Vladimir
Per Ljung
Posted on 20/09/2011 14:58:53
No, it does not work. Look in Templates/Ecom/ProductList/list.html.xslt
The loop is placed inside the product loop, I've even tried with adding static text in the unit loop so that I can see it loops, but nothing is printed.
Best regards,
Per
Vladimir
Posted on 21/09/2011 03:33:28
Hmm... This loop isn't
So to get default unit in productlist you should use extender.
Something like:
Best regards,
Vladimir
available for
product list template, only in the product template..So to get default unit in productlist you should use extender.
Something like:
public class MyProductTemplateExtender : ProductTemplateExtender { public override void ExtendTemplate(Dynamicweb.Templatev2.Template template) { foreach(VariantOption unit in product.UnitList) { if (unit.ID == product.DefaultUnitID){ template.SetTag("Ecom:Product.DefaultUnitName", unit.Name); } } } }
Vladimir
You must be logged in to post in the forum