Hello Community!
I would like get the current selected folder in the product catalog section. How can do that?
Regards,
Like
Hello Federico,
In order to get the current folder id in the product section, you need to subscribe to the ResultFolderFilter message in your replacing client module ProductSectionV2.
Please, see my example - http://prntscr.com/kiucak.
Tetiana Markova,
That's work for ProductSelectionSchema? I´m trying there but is not working for me.
Federico,
I tried the same solution for ProductSelectionSchema and it didn't work for me as well.
So I looked into this case deeper and would like to share my findings with you.
In case you need to get the current folder in the Section (for example, ProductSectionV2 as I did in my previous example) you need to subscribe for the "ResultFolderFilter" message.
Such message is published in the FolderManagerViewModel schema in the applyFolderFilters method.
But in case of ProductSelectionSchema the publication for such message should be done in the ProductCatalogueFolderManagerViewModel, but it is missed. That's why the subscription for such message doesn't work for ProductSelectionSchema. I'll forward such question to our developers' team in order to figure out if there is any reason for that.
If such functionality is crucial for you, the only way to get it work is override applyFolderFilters method in the ProductCatalogueFolderManagerViewModel schema and implement the publication for "ResultFolderFilter" message.
So, you will need to replace the base ProductCatalogueFolderManagerViewModel in your package and modify applyFolderFilters methods in the following way:
applyFolderFilters: function(rowId) {
if (this.get("IsProductSelectMode")) {
var currentItem = this.currentEditElement;
var currentItemType = currentItem.get("FolderType");
var resultFiltersObject = null;
var filtersGroupResult = Terrasoft.createFilterGroup();
var filtersGroup = this.getFolderFilters(rowId);
filtersGroupResult.add("FolderFilters", filtersGroup);
var filterItem = {
filters: filtersGroupResult
};
this.sandbox.publish("UpdateCatalogueFilter", filterItem);
var serializationInfo = filtersGroup.getDefSerializationInfo();
serializationInfo.serializeFilterManagerInfo = true;
resultFiltersObject = {
value: currentItem.get("Id"),
displayValue: currentItem.get("Name"),
filter: filtersGroup.serialize(serializationInfo),
folder: currentItem,
folderType: currentItemType
};
this.sandbox.publish("ResultFolderFilter", resultFiltersObject);
} else {
this.callParent(arguments);
}
}
After that, you'll be able to receive the current folder value in the message handler method in the ProductSelectionSchema schema as was shown in my previous post.
Please, pay attention, that it is not recommended to change the default logic of the base methods to prevent the possible issues in the future releases.