Hello,
Does anyone know how to make a redirect for an inactive product to another product? I cannot fiture out which notifier to use in this occasion...
Best regards, Anders
Hello,
Does anyone know how to make a redirect for an inactive product to another product? I cannot fiture out which notifier to use in this occasion...
Best regards, Anders
You probably want to use Notifications.Ecommerce.Product.BeforeRender and check if it is a product list or product detail page that is being rendered (If ?ProductID=XX)
You can then make a field on the product to choose which product should be redirect to.
BR Nicolai
Hi Nicolai,
This notifier is not hit when a product is deactivated. Do you have any other hints? :-)
Best regards, Anders
Would Dynamicweb.Notifications.Ecommerce.Product.AfterSave be of use? You can see if the product us deactivated there and create a redirect.
@Anders: Because you use 404 on deactivated products? Then you need to go with Imars suggestion.... Or we need to add a BeforeBeforeRender notification - or a product not found notification with a cause...
BR Nicolai
Hi Nicolai & Imar,
For some products I need to have 404, and for the deactivated product it needs to be controlled runtime as it can vary as it depends on the active assortment...
@Nicolai: yes, we have activated 404 of deactivted products. Should we twist this and do the redirect our self for inactive products?
Best regards, Anders
Any thoughts on how to solve this one? :-)
Hi Ander
You have to disable the DontAllowLinksToProductIfNotActive setting and make the decision your self using the BeforeRender notification. If you have an alternative product, do the redirect, otherwise repsonse 404
BR Nicolai
Hi,
we tried the BeforeRender notification without success.
Finally, we did it following these steps:
@{
if(!@GetBoolean("Ecom:Product.IsActive") ) {
string altProduct = "";
if (Loops.Contains("CustomFields")) {
foreach (LoopItem item in GetLoop("CustomFields")) {
altProduct = @item.GetString("InactiveLink.Value");
}
}
if(!string.IsNullOrEmpty(altProduct)) {
HttpContext.Current.Response.Redirect("~/default.aspx?id="+GetGlobalValue("Global:Page.ID")+"&productid="+altProduct);
}
else{
HttpContext.Current.Response.Redirect("~/product-not-found");
}
}
}
Regards,
Tom
You must be logged in to post in the forum