[英]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.