Work with the Catalog Entity Views and Actions API
External systems can exchange catalog-related information using the Catalog Entity Views and Actions API.
The Views and Actions API is an authoring API designed to service a business user interface and is not optimized for integration scenario.
You should consider the following when using the Views and Actions API for your commerce integration:
-
The Views and Actions API can only process one Commerce entity at the time and does not support batch processing.
-
The Views and Actions API carries more overhead than the Commerce web service API. A call to the Views and Action API is typically a 3-step process that requires getting the action's view, modifying the view's properties with updated values, and then executing the action.
Get a catalog (C#)
You can use the Entity Views and Actions API to retrieve a Commerce catalog using C#.
To retrieve a catalog:
DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Catalog-{Id}", "Master", string.Empty, "Entity-Catalog-{CatalogId}");
EntityView view = Proxy.GetValue(query);
Create a catalog (C#)
You can use the Entity Views and Actions API to create a new catalog using C#.
To create a catalog:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($string.empty, "Details", "AddCatalog", string.Empty); EntityView view = Proxy.GetValue(query); -
Provide the name and the display name of the new catalog:
RequestResponsevar Name = view.Properties.FirstOrDefault(p => p.Name.Equals("Name")); var DisplayName = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); Name.Value = "ANewCatalog"; DisplayName.Value = "A New Catalog"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Update the details of a catalog (C#)
You can use the Entity Views and Actions API to modify information details related to a catalog.
To modify a catalog details using C#:
-
Get the entity view for the catalog details:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Catalog-{CatalogId}", Details", "EditCatalog", string.Empty); EntityView view = Proxy.GetValue(query); -
Provide the new catalog details, for example the catalog name or display name:
RequestResponsevar DisplayName = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); DisplayName.Value = "A Newly Renamed Catalog" -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Delete a selected a catalog (C#)
You can use the Entity Views and Actions API to delete a catalog using C#.
To delete a selected catalog:
-
Get the entity view for the catalog:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"",string.Empty,"DeleteCatalog", "Entity-Catalog-{CatalogId}"); EntityView view = Proxy.GetValue(query); -
Execute the delete action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Get a category (C#)
You can use the Entity Views and Actions API to retrieve a catalog category using C#.
To get a category:
DataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-{ParentType}-{ParentId}", string.Empty, string.Empty, "Entity-Category-{CategoryId}");
EntityView view = Proxy.GetValue(query);Create a category (C#)
You can use the Entity Views and Actions API to create a catalog category using C#.
To create a catalog category:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-{ParentType}-{ParentId}", "Details", "AddCategory", string.Empty); EntityView view = Proxy.GetValue(query); -
Provide the new category details, including the name of the category, the display name, and a description, for example:
RequestResponsevar Name = view.Properties.FirstOrDefault(p => p.Name.Equals("Name")); var DisplayName = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); var Description = view.Properties.FirstOrDefault(p => p.Name.Equals("Description")); Name.Value = "ANewCategory"; DisplayName.Value = "A New Category"; Description.Value = "A Category to hold samples"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Update a category (C#)
You can use the Entity Views and Actions API to update the details of a category using C#.
To update the information details of a category:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-Category-{CategoryId}", "Details", "EditCategory", string.Empty); EntityView view = Proxy.GetValue(query); -
Provide the new details for the category, for example the display name and the description:
RequestResponsevar DisplayName = view.Properties.FirstOrDefault(p => p.Name.Equals("DisplayName")); var Description = view.Properties.FirstOrDefault(p => p.Name.Equals("Description")); DisplayName.Value = "Even Hotter Stuff Category"; Description.Value = "Like the Sun Steel Works"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Delete a category (C#)
You can use the Entity Views and Actions API to delete a category from a catalog, using C#.
To delete a category from a catalog:
-
Get the entity view and delete the catalog:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-{ParentType}-{ParentId}",string.Empty,"DeleteCategory","Entity-Category-{CategoryId}"); EntityView view = Proxy.GetValue(query); -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));
Disassociate a category (C#)
You can use the Entity Views and Actions API to remove the association that links a category and a sub-category, for example to remove the association without deleting the category, using C#.
To remove the association:
-
Get the entity view:
RequestResponseDataServiceQuerySingle<EntityView> query = container.GetEntityView($"Entity-{ParentType}-{ParentId}",string.Empty,"DeleteCategory","Entity-Category-{CategoryId}"); EntityView view = Proxy.GetValue(query); -
Disassociate the category:
RequestResponsevar action = view.Properties.FirstOrDefault(p =>; p.Name.Equals("DeleteOption")); action.Value = "Disassociate"; -
Execute the action:
RequestResponseCommerceCommand command = Proxy.DoCommand(container.DoAction(view));