Reputation: 686
I need to add an additional url parameter (which is dynamic and not fixed) to the fields calls that happen on the PDP page. I have tried extending the the product service but that doesnt fire any of my overide functions.
I have now ended up implementing the product adapter so I just want to confirm this is 100% correct.
export class MyProductAdapter implements ProductAdapter {
Upvotes: 1
Views: 721
Reputation: 518
if you want to add a (fixed) value in your fields call you can override the default call and add your missing value. Create a file yourOccProductDetails.config.ts
export const yourOccProductDetailsConfig: OccConfig = {
backend: {
occ: {
endpoints: {
product: {
details: 'products/${productCode}?fields=averageRating,stock(DEFAULT),description,availableForPickup,code,url,price(DEFAULT),numberOfReviews,manufacturer,categories(FULL),priceRange,multidimensional,tags,images(FULL),yourParam',
},
},
},
},
},
And in your module add the config to your providers array
import { yourOccProductDetailsConfig } from './yourOccProductDetails.config'
@NgModule({
imports: [...],
declarations: [YourProductDetailsComponent],
exports: [YourProductDetailsComponent],
providers: [provideConfig(yourOccProductDetailsConfig)],
})
export class YourProductDetailsModule {}
Upvotes: 1
Reputation: 163
Here is the documentation part for a problem you have faced: https://sap.github.io/spartacus-docs/connecting-to-other-systems/#configuring-endpoints
Upvotes: 0