codesenpai_
codesenpai_

Reputation: 55

CMS component configuration using provideConfig changes all similar components

You can provide a CMS component configuration using provideConfig. The following configuration shows how to configure a custom Angular component for the CMS BannerComponent:

provideConfig({
  cmsComponents: {
    BannerComponent: {
      component: CustomBannerComponent;
    }
  }
});

But this will replace all the bannercomponents on the site. How can I replace just one specific bannercomponent?

Upvotes: 0

Views: 347

Answers (1)

CMS component types (flex type for CMSFlexComponent) on Commerce backend are mapped with corresponding component in Spartacus storefront. Hence, the best way to replace one specific banner component is to create a new CMS component in Commerce:

<itemtype code="CustomCommerceBannerComponent" extends="BannerComponent"></itemtype>

and map it to your custom Spartacus component:

provideConfig({
  cmsComponents: {
    CustomCommerceBannerComponent: {
      component: CustomSpartacusBannerComponent;
    }
  }
});

Upvotes: 2

Related Questions