Customize a Commerce view to show or hide information in the Business Tools
The Commerce Views plugin allows you to customize certain aspects of the Business Tools user interface without having to make changes to the Business Tools application itself. For example, you can create a custom plugin that adds a new view property to an existing view. Or you might need to remove elements from the Business Tools UI, such as a child view or a property. You can accomplish these types of customization by extending the appropriate Commerce Engine plugin.
You can also use the Business Tools user interface to add or remove custom child views and properties, but you cannot use it to remove default child views and properties.
To customize a Commerce view, for example, to add or remove a custom child view or property, your must create a custom pipeline block, and configure it to run after the default block it modifies. In the example that follows, we extend the default Customer Entitlements view (entitlementView) to display a gift card's code as a new property. The new pipeline block is named GetCustomerGiftCardCodeViewBlock.
To customize a Commerce view to show or hide information:
-
Create your custom plugin and block. The extension must contain a reference to the
Sitecore.Commerce.Plugin.GiftCardsplugin, because the intent of the customization is to retrieve gift card data. -
The new
GetCustomerGiftCardCodeViewBlockblock must take anEntityViewas a parameter and return anEntityView. -
Add the
runmethod to the custom block. The custom block must first specify the conditions that identify the Commerce entity view to modify.The following illustrates a custom block:
-
Register your custom pipeline and blocks with the Commerce Engine. In your custom plugin project, open the
ConfigureSitecore.csfile, and add the customGetCustomerGiftCardCodeViewBlockblock to theIGetEntityViewPipeline, after theSitecore.Commerce.Plugin.GiftCardsplugin blockGetCustomerGiftCardEntitlementDetailsViewBlock.
Remove a custom child view
To remove a custom Commerce entity:
-
Use the
RemoveChildViewmethod, as shown in the following example:
Remove a custom view property
To remove a custom Commerce view property:
-
Use the
RemoveViewPropertyFromViewmethod as shown in the following example: