- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题:我正在处理自定义搜索框配置,因为我们的搜索 API 端点需要 3 个额外参数。应使用动态参数调用端点。
https://localhost:9002/occ/v2/{baseSiteId}/products/customsearch/param1/param2/param3?query=xyz&pageSize=5&lang=en&curr=USD¤tPage=1
到目前为止,我已收到以下说明:
The searchbox component is delegating the actual search to the SearchBoxComponentService. This service is using the SearchboxService which is a facade around the central store and lower level connectors/adapters. The search box configuration is passed into the facade/store, which you could use to extend the search query that is ending up at the backend.
You should start providing a custom version of SearchBoxComponentService, and override the search() method. If the additional search parameters would match the endpoint configuration query parameters, I believe you're good to go, but honestly i'm doing this from top of head so I might miss something.
基于以上我想出了以下几点:
search(query: string, config: SearchBoxConfig): Observable<SearchResults> {
if (!query || query === '') {
this.clearResults();
return;
}
if (
config.minCharactersBeforeRequest &&
query.length < config.minCharactersBeforeRequest
) {
return;
}
if (config.displayProducts) {
this.ProductSearch(query, {
pageSize: config.maxProducts,
}).subscribe(data => {
return data;
}, error => {
});
}
if (config.displaySuggestions) {
this.searchService.searchSuggestions(query, {
pageSize: config.maxSuggestions,
});
}
}
// tslint:disable-next-line: typedef
ProductSearch(query: string, searchConfig?: SearchConfig): Observable<SearchResults> {
const pageSize = searchConfig.pageSize ? searchConfig.pageSize : 5;
const currentPage = searchConfig.currentPage ? searchConfig.currentPage : 1;
const fetchUrl = `${this.occEndpointsService.getBaseEndpoint()}/products/markethubsearch/${this.soldTo}/${this.shipTo}/${this.businessCategory}?query=${query}&pageSize=${pageSize}&lang=en&curr=USD¤tPage=${currentPage}`;
return this.http.get<SearchResults>(fetchUrl, {
params: new HttpParams().set('fields', 'FULL')
});
}
但是,我仍然无法订阅 SearchResults 可观察对象。你能帮我解决这个问题吗?
最佳答案
感谢您的提问。我想当我最初回答你时,我忽略了一些事情。
首先,SearchBoxComponentService.search
不仅获取搜索配置并将其传递给 SearchboxService
。它只从配置中获取细节。因此,我建议改写 SearchboxService
,即:
@Injectable({
providedIn: 'root',
})
export class CustomSearchboxService extends SearchboxService {
search(query: string, config?: SearchConfig): void {
super.search(query, { ...config, foo: 'bar' } as SearchConfig);
}
}
使用此设置,您的配置将最终处于操作状态,因此可在 OccProductSearchAdapter
中使用。适配器将使用 searchConfig
创建端点。
您现在可以通过向 Spartacus 提供配置来使用动态参数来配置您的搜索端点:
provideConfig({
backend: {
occ: {
endpoints: {
productSearch:
'products/search?fields=products(code)&foo=${foo}'
}
}
}
})
但是,这将不允许动态路径属性。我会和团队谈谈,看看我们是否可以允许这样做。您也许可以更改端点以改为使用查询参数,这样您就可以开始了。
要使用路径参数,您需要评估这些方法:
OccProductSearchAdapter
并实现 getSearchEndpoint
。您可以利用 searchConfig
参数并输入路径参数。关于spartacus-storefront - SPARTACUS 自定义 SearchboxComponent 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64480593/
如何设置单个 Spartacus 应用程序以针对单个 BA Hybris(多个 Base Store)运行多个不同的网络商店。 我们需要确保用户 session 不混合。 斯巴达克斯的配置是什么,最终
可能我的问题有点愚蠢,因为有很多关于路由的文档。问题是,我不是角度专家,所以我缺少一些上下文。 我想向 spartacus 添加一个自定义子页面 ( http://localhost:4200/ima
我正在将我的解析器(从 PageMetaResolver 扩展)添加到我自己的 home.module 中的提供程序中。但是,没有调用我的方法“解决”。你有什么想法吗? @Injectable({
有什么方法可以覆盖 SAP Spartacus v3.x+ 中的 OccStoreFinderAdapter 类吗?我已经尝试过的是像这样在 store-finder-feature.module.t
问题:我正在处理自定义搜索框配置,因为我们的搜索 API 端点需要 3 个额外参数。应使用动态参数调用端点。 https://localhost:9002/occ/v2/{baseSiteId}/pr
我们目前正在使用三种不同的环境(dev、stage、prod)在 CCv2 上设置一个 Spartacus 应用程序。 我们正在努力在 Spartacus 中为环境设置正确的 OCC API Urls
我们的 Hybris 实例有一些自定义的 REST API,例如 addEntry。这个版本的 API 需要在有效载荷中有一个额外的 bool 参数,我们称之为 fooBar。 下面是一个有效载荷的例
由于 Spartacus 适用于 B2C 流程,所以没有任何选项可以从店面更改 BaseStore。我有不同国家/地区的下拉菜单,现在想从中更改 BaseSite。 最佳答案 所以我终于成功了。如果
尝试使用 2011 Commerce Cloud 和 spartacussampledata 设置本地 spartacus。很少有 restful 端点抛出 401 未经授权的访问。点击此链接进行设置
默认情况下,Spartacus 产品列表页面上的分页也会对 10 个产品进行分页。 我希望 PLP 在分页中有 24 个产品。我在 Java 中自定义了 OCC/搜索服务,我在浏览器的网络下看到 pa
我使用了 this.outletService.add('BottomHeaderSlot', factory, OutletPosition.BEFORE);在搜索按钮单击处理程序期间,在 Bott
我们正在尝试扩展 ProductListComponent,因此我们创建了: export class CustomProductListComponent extends ProductListCo
在 SAP Commerce 中,我准备了自定义 CMS 组件。我把它放在正确的插槽中。 Spartacus 收到有关它的信息 - 我可以看到该组件在页面上的正确位置。但是我怎样才能从这个组件中检索一
我按照 https://sap.github.io/spartacus-docs/installing-sap-commerce-cloud-2005/ 上的说明进行操作 第一步:完成成功 第 2 步
我们在结合使用 Spartacus、Angular 和 Storybook 时遇到了问题。 对于那些不熟悉的人:Storybook 是一个 UI 开发环境,它能够以一种独立的方式展示 UI 组件,并具
关于模块/类型增强的 spartacus 文档说它在 spartacus 2.1 中受支持。 https://sap.github.io/spartacus-docs/type-augmentatio
我的问题是,我可以将 React 框架与 @spartacus 店面一起使用吗?这是因为我们的前端应用程序是在 React 中开发的,我们希望使用 @Spartacus 店面来利用前端解耦和 Hybr
我正在尝试获取自定义组件的组件数据。 private componentData$: Observable = this.componentData.data$.pipe( filter(Bo
有没有办法可以在 Hybris 6.2 上运行 Spartacus? 我在本地主机计算机上运行 6.2。 SAP 网站说必须是版本 18 及以上。 谢谢 最佳答案 我认为你不能。 来自:https:/
我是一名优秀的程序员,十分优秀!