Description :
Gets information about the current category, including the parent URL, any sibling categories, and any child categories. This method works only when the view is a category page. Commerce categories enable you to organise items in a hierarchical structure called a catalogue. Items are then displayed on your SuiteCommerce website using the same hierarchical structure.
Code :
var plp = container.getComponent('PLP');
var categoryinfo = plp.getCategoryInfo();
var categoryname = categoryinfo.name;
var categorypage = categoryinfo.fullurl;
if (categroypage.indexOf("sports") >= 0) {
alert("Special offer on all sports clothes and equipment until the end of the month!");
}
// Example of the object returned by getCategoryInfo()
{
addtohead: "",
breadcrumb: Array [],
categories: [
{
name: "Climbing",
internalid: "37",
sequencenumber: "0",
...
},
{
name: "Ski",
internalid: "38",
sequencenumber: "1",
...
}
],
description: "",
fullurl: "/sports",
internalid: "35",
name: "Sports Clothes and Equipment",
pagetitle: "Sports Clothes and Equipment",
parenturl: "",
...
}
Output :
Returns
Object
Returns a CategoryInfo object if the current view is category page. If the view is not a category page, it returns undefined. The CategoryInfo object includes the following properties:
categories– An array of child categories of the current category. Each child category is an object with its own set of properties, such asdescription,fullurl,internalid, andname.description– The description of the category.internalid– The internal ID of the commerce category record in NetSuite.fullurl– The full URL of the category. In NetSuite, the full URL of a commerce category is the path part of the URL after the domain name.name– The name of the category.pagetitle– The title of the page.parenturl– The full url of the parent category (if the current category has a parent category).