layout.addToViewContextDefinition('Header.MiniCart...
# suitecommerce
g
layout.addToViewContextDefinition('Header.MiniCartItemCell.View', 'itemId', 'string', function itemId(context) { var itemId=context.line.internalid; return itemId }); When we wrie this code ,i am getting below issue
m
Check
addToViewContextDefinition
in this doc for ref.
Try this and don't forget to add
Header.MiniCartItemCellView.View
as a dependency.
HeaderMiniCartItemCellView.addExtraContextProperty(
'itemId',
'string',
function(context) {
return context.line.internalid;
}
);
s
Hi, it is not good practice to invoke
addExtraContextProperty
like this for three reasons: 1. The method is deprecated 2. The method is internal to the core view class 3. To use it in an extension, you must add the view you want to modify as a dependency which will be blocked in a future release of SC, thus breaking this customisation
addToViewContextDefinition
is the correct method to use. I tested your code in my browser console and it worked just fine, so can you give more information about how you are using it?
m
Thanks @Steve Goldberg for updating on the deprecation. I will update my team on this.
g
I want to change the item internalid in header mini cart.how we are showing the internalids in cart page like that.i am getting same results what I expected ,but in console I am seeing this error