Adding Metafields to Store detail blade

Hi. I’m attempting to add a Metafield to the blade defined in store-details.js in VirtoCommerce.StoreModule repo.

There is a va-metaform tag in the store-detail.tpl.html, but the virtoCommerce.storeModule.storeDetailController never sets the metaFields on the blade, similar to what is done in the itemDetailController in CatalogModule with the line:
blade.metaFields = metaFormsService.getMetaFields(“productDetail”);

Is there a way to register a new metafield and set the store-details blade property to get that metafield, without changing the StoreModule code?

Hello, thanks for notifying us. Yes, unfortunately it’s a bug in storeDetailController, metaFormsService is not being called in storeDetailController. We’ll register the bug internally.

However, there’s a workaround without changing storeDetailController if you have your own extension module. Add this code to your custom module.cs:

angular.module('platformWebApp')
.config(['$provide', function ($provide) {
    $provide.decorator('platformWebApp.bladeNavigationService', ['$delegate', function ($delegate) {
        var service = $delegate;

        var showBlade = service.showBlade;

        service.showBlade = function (blade, parentBlade) {
            showBlade(blade, parentBlade);

            //init your own metafields for storeDetails blade here
            if (blade.id === "storeDetails") {
                blade.metaFields = [{
                    name: 'startDate',
                    isReadOnly: true,
                    title: "Data created",
                    valueType: "DateTime"
                }]
            }
        };

        return $delegate;
    }]);
}]);

This code will override bladeNavigationService.showBlade function: on each showBlade call it will execute base showBlade func first then add metaFields to storeDetails blade.

2 Likes

Thank you for your response and your help, that workaround worked nicely.

1 Like