I am creating a custom extension that retrieves it...
# suitecommerce
z
I am creating a custom extension that retrieves item information on the PDP (Product Detail Page), formats the price, calculates the savings price, and displays it. I am using addToViewContextDefinition for this, which sends it to "ProductView.Price.View". This price is being shown on both the PDP and related items. When I click on a related item, the page doesn't change, and the console shows this error: "Exception on event handler for event beforeShowContent DUPLICATED_CONTEXT_PROPERTY: Duplicated propertyName. Trying to add more than one extra context property with the same name." Any help would be appreciated!
s
Just like another person has found out, it sounds like you're modifying the view class using a beforeShowContent event which means that it's trying to add this property every time you visit a PDP
You should only call addToViewContextDefinition once, preferably in your entry point file
z
I am using PDP component something like this PDP.on("beforeshowcontent",funtion (){ //my logic here layout.adddChildView() }
So it is adding context proerty everytime when PDP gets load
s
Yeah, so don't do that
z
So what should be the best alternate to achieve this ?
s
Don't wrap it in a beforeShowContent event listener