Hi,
2 questions :-)
First, I need to make a custom tag that prints out part of a BOM-group-name. How do you get the value of the current BOM-group in the product-template-extender? Name of the product is this.Product.Name, but i can't seem to get the name of the different BOM-groups of the product.
Secondly if i make a custom tag like this:
template.SetTag("PartlistGroupMinimumValue", "TEST");
In the Product-template i can't fetch the tag if i'm inside the loop. If i'm outside the loop, however, it is no problem.
I hope You can help with the problems :-)
Developer forum
E-mail notifications
Custom Tag for product template
Posted on 27/04/2011 11:38:08
Replies
Nicolai Høeg Pedersen
Posted on 27/04/2011 11:49:41
Accessing the BOM
For Each Item As ProductItem In Product.Items
If Item.BomGroupID = String.Empty Then
'Product
Else
'Configurator (group of products)
item.name 'The name of the group...
For Each prod As Product In Item.Products
Next
End If
Next
#2
If the template tag needs to be available inside the loop, put the settag inside the loop also:
Dim Template As Templatev2.Template = ParentTemplate.GetLoop(LoopName)
For Each thing in thingcollection
Template.SetTag("PartlistGroupMinimumValue", "TEST")
Template.CommitLoop()
Next
For Each Item As ProductItem In Product.Items
If Item.BomGroupID = String.Empty Then
'Product
Else
'Configurator (group of products)
item.name 'The name of the group...
For Each prod As Product In Item.Products
Next
End If
Next
#2
If the template tag needs to be available inside the loop, put the settag inside the loop also:
Dim Template As Templatev2.Template = ParentTemplate.GetLoop(LoopName)
For Each thing in thingcollection
Template.SetTag("PartlistGroupMinimumValue", "TEST")
Template.CommitLoop()
Next
Posted on 27/04/2011 13:58:27
Hi,
Thanks for a quick reply :-)
It almost works now, but we still have a problem.
The changes we have made now result in Dynamicweb printing out the original loop first (Without our custom-tags set) and then afterwards it prints out the loop again - with our custom-tags set and all normal tags not set.
You can see it here: http://saltogpeber.net.dynamicweb.dk/da-DK/Menuoversigt/Buffet-oversigt/Buffet-1.aspx
The code is here:
Thanks for a quick reply :-)
It almost works now, but we still have a problem.
The changes we have made now result in Dynamicweb printing out the original loop first (Without our custom-tags set) and then afterwards it prints out the loop again - with our custom-tags set and all normal tags not set.
You can see it here: http://saltogpeber.net.dynamicweb.dk/da-DK/Menuoversigt/Buffet-oversigt/Buffet-1.aspx
The code is here:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Dynamicweb;
using System.Web.UI.WebControls;
using Dynamicweb.eCommerce.Products;
namespace CustomModules.CustomModules.PriceUpdater
{
public class ProductTemplateExtender1 : ProductTemplateExtender
{
public override void ExtendTemplate(Dynamicweb.Templatev2.Template template)
{
Dynamicweb.Templatev2.Template temp = template.GetLoop("BOMConfigurators");
foreach (ProductItem i in Product.Items)
{
if (i.BomGroupID == String.Empty) {
// Do nothing
}
else
{
string bomNameTest = i.Name;
string bomNameMinimum = "";
string bomNamePrice = "";
string bomNameMenu = "";
List parts = bomNameTest.Split('[').Select(asd => asd.Trim()).ToList();
foreach (string part in parts)
{
if (part.Contains("minimum:"))
{
bomNameMinimum = part;
bomNameMinimum = bomNameMinimum.ToLower();
bomNameMinimum = bomNameMinimum.Replace("minimum:", "");
bomNameMinimum = bomNameMinimum.Replace("]", "");
bomNameMinimum.Trim();
}
if (part.Contains("pris:"))
{
bomNamePrice = part;
bomNamePrice = bomNamePrice.ToLower();
bomNamePrice = bomNamePrice.Replace("pris:", "");
bomNamePrice = bomNamePrice.Replace("]", "");
bomNamePrice.Trim();
}
if (part.Contains("menu:"))
{
bomNameMenu = part;
bomNameMenu = bomNameMenu.ToLower();
bomNameMenu = bomNameMenu.Replace("menu:", "");
bomNameMenu = bomNameMenu.Replace("]", "");
bomNamePrice.Trim();
}
}
temp.SetTag("PartlistGroupMinimumValue", bomNameMinimum);
temp.SetTag("PartlistGroupPrice", bomNamePrice);
temp.CommitLoop();
}
}
}
}
}
Posted on 28/04/2011 11:06:10
Any updates on this, as we need this fixed asap?
Thanks for the help :-)
Thanks for the help :-)
Posted on 28/04/2011 14:25:06
Is it at all possible to add the tag to the exsisting loop (BOMConfigurators) or do i have to make a new not-standard-ecom loop?
Nicolai Høeg Pedersen
Posted on 28/04/2011 17:17:21
You cannot extend a loop in the product template...
You can make your own loop though.
You can make your own loop though.
Posted on 03/05/2011 09:06:57
Thanks for the reply :-)
We found another solution!
We found another solution!
You must be logged in to post in the forum