Developer forum

Forum » Ecommerce - Standard features » Access discontinued property

Access discontinued property

Andreas Pettersson
Reply

Hi,

I run dynamicweb 9.10.8 but it seems I can not access the discontinued property in my HTML template? 

I tried this in my html but it seems to be false all the time: 
productObject.discontinued = product.GetBoolean("Ecom:Product.ProductDiscontinued");

If I look in this there is no property for discontinued.
https://doc.dynamicweb.com/template-tags/ecommerce/product-catalog/product

In settings => Ecommerce => product catalog => product fields I see a field called discontinued.

Regards
Andreas

discontinued.PNG discontinued2.PNG

Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

"Ecom:Product.Discontinued" is the correct name of the tag.

You can use @TemplateTags() or @{loopItem}.TemplateTags() to get a list of valid template tags and their values in any context.

BR Nicolai

Votes for this answer: 1
 
Andreas Pettersson
Reply

Hi,

Thanks. 

Can I somehow get the replacement product name also ?

/Andreas

 
Nicolai Pedersen
Reply

You have Ecom:Product.ReplacementProductId and Ecom:Product.ReplacementVariantId

Then you can use the productservice to get the product

@{
var productid = GetString("Ecom:Product.ReplacementProductId");
var variantid = GetString("Ecom:Product.ReplacementVariantId");
var replacementProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(productId, productVariantId, Common.Context.LanguageID);
var productName = replacementProduct .Name;
}

Be careful not to do this on product lists as it can affect performance.

 
Andreas Pettersson
Reply

Thank you! 
I will try it out.

/Andreas

 

You must be logged in to post in the forum