Search code examples
customizationsap-commerce-cloudspartacus-storefrontcommerce

How to create a new OccEndpoints in Spartacus


I created a new page in Spartacus. On this page, I also wrote the necessary services to receive the data from the backend. I created a WSDTO class for my new page. As with PDP - PLP pages when the page is opened, Google vs. I also made the fieldSetLevelMapping settings in the Network field in browsers.

But I am getting an error in spartacus because my new page in spartacus is not defined in OccEndpoint. How can I define a new page in Spartacus like default pages in OccEndpoint.

This is how data comes in under Network in PLP. This way I want the data inside my new sheet. How can I do this?

enter image description here

What I did in the backend: Populator class and Controller class are also available.

enter image description here

enter image description here

enter image description here

What I did in Spartacus:

enter image description here

ERROR : enter image description here


Solution

  • Could you check this way?

    import { OccConfig, OccEndpoint } from '@spartacus/core';
    
    export interface YourOccEndpoints {
      wishListDcatalog?: string | OccEndpoint;
    }
    
    declare module '@spartacus/core' {
      interface OccEndpoints extends YourOccEndpoints {}
    }
    

    and

    const yourOccEndpoints: YourOccEndpoints = {
      wishListDcatalog: '...',
    };
    
    export const yourOccConfig: OccConfig = {
      backend: {
        occ: {
          //...
          endpoints: {
            ...yourOccEndpoints,      
          },
        },
      },
    };       
    

    then provide it in your app module provideConfig(yourOccConfig),