简体   繁体   English

需要在 Spartacus 4.3 中自定义 OOTB '/search' PLP API (GET to POST)

[英]Need to customize OOTB '/search' PLP API (GET to POST) in Spartacus 4.3

We are trying to hit the search api with custom query param but the length of query param is too long, /search api is failing because it is a GET call.我们正在尝试使用自定义查询参数来搜索 api,但查询参数的长度太长,/search api 失败,因为它是 GET 调用。

How we can customize the OOTB /search (GET) API into a POST call with custom payload and use all existing functionalities coming from /search API in Spartacus 4.3.我们如何将 OOTB /search (GET) API 自定义为带有自定义负载的 POST 调用,并使用 Spartacus 4.3 中来自 /search API 的所有现有功能。

We tried updating the ProductsSearchEffect to our custom Effect by using useClass and writting the custom service for search as POST method but code is not reading our custom Effect and it is still reading OOTB ProductsSearchEffect.我们尝试使用 useClass 将 ProductsSearchEffect 更新为我们的自定义 Effect,并将用于搜索的自定义服务编写为 POST 方法,但代码未读取我们的自定义 Effect,它仍在读取 OOTB ProductsSearchEffect。

You can customize the communication with the backend Search endpoint (eg to use POST http method, or to use a different endpoint URL, whatever...), by extending the class OccProductSearchAdapter and overwriting it's method search() .您可以通过扩展 class OccProductSearchAdapter并覆盖它的方法search()来自定义与后端搜索端点的通信(例如,使用POST http 方法,或使用不同的端点 URL,等等...)。 See the followin example:请参阅以下示例:

@Injectable({providedIn: 'root'})
export class CustomOccProductSearchAdapter extends OccProductSearchAdapter {
   override search( /* ... */) {
      /* ... */
      return this.http.post( /* ... */ );
   }
}
{
   provide: ProductSearchAdapter
   useExisting: CustomOccProductSearchAdapter
}

For reference, see the default implementation of OccProductSearchAdapter .作为参考,请参阅OccProductSearchAdapter的默认实现

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 12 升级后样式问题 - Angular 12 post-upgrade styling issue 如何使用 Angular 通过 POST 请求的查询参数传输数据? - How to transfer data via query params of a POST request, using Angular? 需要从 [object][object] 获取一个值 - Need to get one value from [object][object] 我们可以对 Angular 中的 API 数据进行 if 检查吗? - Can we do a if Check to API data in Angular? 如何访问 FormGroup 中的属性? 我需要访问一些属性(触摸和错误) - How I can access my properties inside the FormGroup? I need to access some properties (touched and errors) Angular 12 升级错误:您可能需要合适的加载器来处理此文件类型,目前没有配置加载器来处理此文件 - Angular 12 upgrade error: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file Angular 12 升级问题:您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件 - Angular 12 upgrade issue : You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file 如何在没有 api 调用 ngrx 存储的情况下更新 state 数据? - How to update state data without api call with ngrx store? 如何停止或等待其他 api 调用直到令牌存储在 angular12 中 - how to stop or wait other api call untill token is stored in angular12 Angular 12:在异步获取结果后 ngModel 变量未更新 - Angular 12: ngModel variable not updating after async get result
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM