In SuiteCommerce Advanced (SCA), you can add the category fullurl to a template and then access this value from the entry point file (JavaScript controller). Here’s how you can achieve this:
Adding Category fullurl to Template:
In your template file (for example, CategoryTemplate.js), you can access the category fullurl property if the category object is available in your template context. For instance, assuming your template context contains a category object, you can directly access category.fullurl in your template logic.
// CategoryTemplate.js
define('CategoryTemplate', ['underscore', 'Backbone', 'Utils'], function (_, Backbone, Utils) {
'use strict';
return Backbone.View.extend({
template: 'category_template',
getContext: function () {
var category = this.model; // Assuming your category model is available in this.model
return {
categoryName: category.get('name'),
categoryFullUrl: category.get('fullurl') // Accessing category fullurl property
};
}
});
});
In this example, category.get('fullurl') retrieves the fullurl property of the category model and adds it to the template context.
Accessing Category fullurl in Entry Point File:
In your entry point file (for example, CategoryEntryPoint.js), you can pass the categoryFullUrl value to any modules or components that need to use it.
// CategoryEntryPoint.js
define('CategoryEntryPoint', ['CategoryTemplate'], function (CategoryTemplate) {
'use strict';
var categoryModel = /* fetch or create your category model */;
var categoryView = new CategoryTemplate({
model: categoryModel
});
// Render the category view and access category fullurl from the template context
categoryView.render();
var categoryFullUrl = categoryView.getContext().categoryFullUrl;
// Now you can use categoryFullUrl in your logic
console.log('Category Full URL:', categoryFullUrl);
// ... rest of your entry point logic
});
In this example, categoryFullUrl is accessed from the template context after rendering the CategoryTemplate view. You can then use this value in your entry point logic or pass it to other modules/components as needed.