- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 01:44 AM - edited 11-03-2022 01:45 AM
hide all catalog items in popular list
and specifically hide some catalog item in popular list
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 04:24 AM - edited 11-03-2022 04:30 AM
Unfortunately, that link's solution is no more relevant for current version
Follow the below steps in sequence:
1. Create a properties with name exclude_from_popular_list and put the sys_id(s) of the catalog items that you want to exclude from the portal (comma separated)
2. Open service portal and category page where you see popular items. Now press ctrl + right click on Popular Items and click on Widget in Editor option.
Create a clone of SC category page widget, as shown below:
3. Now open your Cutom Category Page which you just now created
4. Go to function name getPopularItems() and replace it with below script and save the widget:
function getPopularItems() {
var itemsToExclude = gs.getProperty("exclude_from_popular_list");
return new SCPopularItems().useOptimisedQuery(gs.getProperty('glide.sc.portal.popular_items.optimize', true) + '' == 'true')
.baseQuery(options.popular_items_created + '')
.allowedItems(getAllowedCatalogItems())
.visibleStandalone(true)
.visibleServicePortal(true)
.itemsLimit(6)
.restrictedItemTypes('sc_cat_item_guide,sc_cat_item_wizard,sc_cat_item_content,sc_cat_item_producer'.split(','))
.itemValidator(function(item, itemDetails) {
if(itemsToExclude.indexOf(itemDetails.sys_id)>-1)
return false;
if (!item.canView() || !item.isVisibleServicePortal())
return false;
return true;
})
.responseObjectFormatter(function(item, itemType, itemCount) {
return {
order: 0 - itemCount,
name: item.name,
short_description: item.short_description,
picture: item.picture,
price: item.price,
sys_id: item.sys_id,
hasPrice: item.price != 0,
page: itemType == 'sc_cat_item_guide' ? 'sc_cat_item_guide' : 'sc_cat_item'
};
})
.generate();
}
5. Now go to the SC Category page in designer and drag and drop the Custom Category Page widget over SC Category page widget as shown below. As of now we are not deleting the OOB SC Category Page widget purposefully, for comparing the result:
6. Now go to the Portal and see items that you excluded is no more showing in popular items list. You can compare from the pre existing widget, we have kept it one below another to compare.
7.Once you are staisfied with the result, delete the previous SC Category page widget. And you are done with your requirement.
As and when you want to allow any already removed item or add furhter item to remove from Popular items list just make change in the properties and it will reflect on the portal.
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 02:25 AM
Hi @Giriprasath ,
Please try the below link, it should resolve your issue:
I Hope this helps.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 02:28 AM
I already seen that post but I can't understand that will anyone give me step by step process please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 04:24 AM - edited 11-03-2022 04:30 AM
Unfortunately, that link's solution is no more relevant for current version
Follow the below steps in sequence:
1. Create a properties with name exclude_from_popular_list and put the sys_id(s) of the catalog items that you want to exclude from the portal (comma separated)
2. Open service portal and category page where you see popular items. Now press ctrl + right click on Popular Items and click on Widget in Editor option.
Create a clone of SC category page widget, as shown below:
3. Now open your Cutom Category Page which you just now created
4. Go to function name getPopularItems() and replace it with below script and save the widget:
function getPopularItems() {
var itemsToExclude = gs.getProperty("exclude_from_popular_list");
return new SCPopularItems().useOptimisedQuery(gs.getProperty('glide.sc.portal.popular_items.optimize', true) + '' == 'true')
.baseQuery(options.popular_items_created + '')
.allowedItems(getAllowedCatalogItems())
.visibleStandalone(true)
.visibleServicePortal(true)
.itemsLimit(6)
.restrictedItemTypes('sc_cat_item_guide,sc_cat_item_wizard,sc_cat_item_content,sc_cat_item_producer'.split(','))
.itemValidator(function(item, itemDetails) {
if(itemsToExclude.indexOf(itemDetails.sys_id)>-1)
return false;
if (!item.canView() || !item.isVisibleServicePortal())
return false;
return true;
})
.responseObjectFormatter(function(item, itemType, itemCount) {
return {
order: 0 - itemCount,
name: item.name,
short_description: item.short_description,
picture: item.picture,
price: item.price,
sys_id: item.sys_id,
hasPrice: item.price != 0,
page: itemType == 'sc_cat_item_guide' ? 'sc_cat_item_guide' : 'sc_cat_item'
};
})
.generate();
}
5. Now go to the SC Category page in designer and drag and drop the Custom Category Page widget over SC Category page widget as shown below. As of now we are not deleting the OOB SC Category Page widget purposefully, for comparing the result:
6. Now go to the Portal and see items that you excluded is no more showing in popular items list. You can compare from the pre existing widget, we have kept it one below another to compare.
7.Once you are staisfied with the result, delete the previous SC Category page widget. And you are done with your requirement.
As and when you want to allow any already removed item or add furhter item to remove from Popular items list just make change in the properties and it will reflect on the portal.
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 12:30 AM
Hi @Giriprasath ,
Could you please update if this worked for you or you had any challanges?
Regards,
Kamlesh