Search code examples
spartacus-storefront

Extending the PDP routes in spartacus?


May I know how to implement this custom route in spartacus ? product/:productCode/:name/order-form

I tried implementing this in my custom order-form-routes.module.ts But it doesn't seem to recognize this config as it throws a Page Not Found error.

ConfigModule.withConfig({
  routing: {
    routes: {
      orderForm: {
        paths: ['product/:code/:name/order-form'],
        paramsMapping: { code: 'code', name: 'name' },
      },
    },
  },
}),

Solution

  • considering @Platonn's suggestion: This config made it work:

    RouterModule.forChild([
      {
        path: 'product/:code/:name/order-form',
        canActivate: [AuthGuard, CmsPageGuard],
        component: PageLayoutComponent,
        data: { pageLabel: '/order-form' },
      },
    ]),