Developer forum
E-mail notifications
Search module - and ecom etc
I have ecom integrated, and need the URL to be dynamic, regarding where the link throws you in the search.
For instance, If I have a category called "actors" - this is the URL:
/actors?productID=PROD1
And a category called "products" - this is the URL:
/products?productID=PROD2
I need the search results to be able to link to these so called URLS, and not just one of them.
Is this possible?
Replies
It’s possible with productTemplateExtender.
I have prepared an example.
using Dynamicweb;
using Dynamicweb.eCommerce.Products;
namespace CustomModules1
{
public class SearchProductTemplateExtender : ProductTemplateExtender
{
public override void ExtendTemplate(Dynamicweb.Templatev2.Template template)
{
Dynamicweb.Frontend.PageView pv = Dynamicweb.Frontend.PageView.Current();
string url = "default.aspx?id={0}&GroupID={1}&ProductID={2}";
string groupid = Product.Groups.get_Item(0).ID; // take first group from product groups
template.SetTag("myCustomLink", string.Format(url,pv.ID, groupid, Product.ID));
}
}
}
then you can use myCustomLink tag in your product list template.
Or you can override existed tag, for example:
template.SetTag("Ecom:Product.LinkGroup.Clean", string.Format(url,pv.ID, groupid, Product.ID));
I am not a developer, so I have no access to these files.
basically, I need a way , without coding .NET:)
Regards
Bump. Does anyone else have a solution to differentiate in the search template, so I can decide if the link should goto A or B regarding products in ecom?
perhaps via razor templates if nesecary?
Hi Jan
The principle in Yurys post above can be used in a Razor template. That is the only option for now.
We are working on a solution so you can see what kind of data is in the search result, but it is not ready yet.
Nicolai
Hi Jan,
We needed to provide this as well. The solution we found was to create a custom field on the product to assign the page the product should be seen in (Detail main page).
Then the search result sends the user to a specific page with a Razor template redirecting to the correct page.
It's a problem because we need to set that field for all language variants and if the product catalogue is shared with multiple sites, we need to create multiple fileds but we managed (few products though)
Best Regards,
Nuno
Hi Nicolai,
Could I overwrite the link coming from the searchmodule in the razor template for the searchlistings?
Or should this logic be applied in the master template for example or somewhere else?
@Nuno Ty for the reply. Perhaps that is the way it ends up here too. All depends on how easy the fix Yury has is:)
Hi Jan
Yes you can overwrite the link coming from the searchmodule directly in your search result item template. You can put the link into a variable:
@{ var link = GetValue("DwSearchResultHref"); }
And when it is in the variable, you can manipulate it in anyway, look up things from the API etc.
BR Nicolai
You must be logged in to post in the forum