Set "Same permissions for child categories and products" in permissions tab checkbox from code

Hello!
I have a question regarding how to from code, check the “Same permissions for child categories and products” in the permissions tab of an assortment. I wasn’t able to find anything in the Assortment object itself. Is this possible and if so, any tips on how to do this would be greatly appreciated, thanks :slight_smile:

Litium version: 7.4.2

It’s not possible from the entity services directly, but maybe you could try and piggy-back on some of the behind-the-scenes-actions used when performing that action from the UI.

Might not be future-proof, you’d be very welcome to make a suggestion in our Ideas portal to add this as a service or similar.

var assortmentHandler = new AssortmentPermissionEditorHandler(
	_authorizationService,
	_assortmentService,
	_groupService,
	_dataService,
	_categoryService,
	_baseProductService);

var categoryPermissionModelEditorHandler = new CategoryPermissionModelEditorHandler(
	_categoryService, 
	_authorizationService, 
	_groupService, 
	assortmentHandler);

var model = new CategoryPermissionModel
{
	OwnerId = categorySystemId,
	GroupPermissionList = new List<EntityPermissionModel>() {
		new EntityPermissionModel
		{
			GroupSystemId = groupSystemId,
			Readable = true,
		}
	},
	Propagate = true,
};

categoryPermissionModelEditorHandler.SaveAsync(model);
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.