Jira Code: IBT-36: Move header content to theme and Extension
A simple SCA extension to add/replace a new variable inside the context method of a view/entry point file. We use “addToViewContextDefinition” for this.
define(
'JJ.TBTExtensions.HeaderExtension', [
'JJ.TBTExtensions.HeaderExtension.View'
],
function(
HeaderExtensionView
) {
'use strict';
return {
mountToApp: function mountToApp(container) {
// more documentation of the Extensibility API in
// https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/index.html
/** @type {LayoutComponent} */
var layout = container.getComponent('Layout');
console.log('layout',layout)
if (layout) {
layout.addToViewContextDefinition('Header.Menu.View', 'categories', 'array', function(context) {
var categories = context.categories
var filteredCategories = _.filter(categories, function filter(category) {
return category.href && !~category.href.toLowerCase().indexOf('browse-by-game');
});
return filteredCategories;
});
}
}
};
});