Show all items of all the categories instead of Popular items

Nishant16
Tera Expert

 How can i show all the items belonging to all catalogs and the categories available for a user in this Sc category widget instead of just showing the Popular items, How can i achieve this?

find_real_file.png

13 REPLIES 13

Hello, 

I don't want to show popular item and i don't want to show Catalog.

I want to show Category--> "getAllowedCategoryItems()" from table "sc_category" but don't work. Do you have any idea?

 

Thanks

Nishant16
Tera Expert

Thanks Shivani, i am able to do it using below complete code, i am sharing this for others who may face this issue:

 

function getPopularItems() {
var items = [];
var allowedItems = getAllowedCatalogItems();
var count = new GlideRecord('sc_cat_item');
count.orderBy('name');
count.addQuery('sys_id', "IN", allowedItems);
count.addEncodedQuery('active=true');
count.query();
while (count.next()) {
var catalogItemJS = new sn_sc.CatItem(count.getValue('sys_id'));
if (!catalogItemJS.canView() || !catalogItemJS.isVisibleServicePortal())
continue;
var item = {};
var catItemDetails = catalogItemJS.getItemSummary();
item.name = catItemDetails.name;
item.short_description = catItemDetails.short_description;
item.sys_id = catItemDetails.sys_id;
item.page = 'sc_cat_item';
item.type = catItemDetails.type;
item.sys_class_name = catItemDetails.sys_class_name;
if (item.type == 'content_item') {
item.content_type = catItemDetails.content_type;
item.url = catItemDetails.url;
if (item.content_type == 'external') {
item.target = '_blank';
}
}
items.push(item);
}

return items;
}

Mary S
Mega Sage

This works great.

@Shivani M S -- Is there a way to sort by popularity instead of name?

Suraj Ranabhat
Tera Contributor

Alternative approach without modifying OOTB "sc_category page" widget:

In the widget instance, change sc_category page to Catalog item page which will add "sp?id=catalog_items" to the instance URL and show up all items.