0

实际上我创建了一个新的 ProductListComponent 和一个新的 ProductListComponentService,它们的代码与原来的代码相同,我只是在 ProductListComponentService 处更改了值protected defaultPageSize但它没有效果。

有任何想法吗?

我的产品列表组件

export class CustomProductListComponent {
  model$: Observable<ProductSearchPage> = this.productListComponentService
    .model$;

   constructor(private pageLayoutService: PageLayoutService, private productListComponentService: ProductListComponentService, private cd: ChangeDetectorRef,
    private scrollConfig?: ViewConfig) {
    }
}

原始源代码:https ://sap.github.io/cloud-commerce-spartacus-storefront/components/ProductListComponent.html#source

我的产品列表组件服务

@Injectable({ providedIn: 'root' })
export class ProductListComponentService {
  protected defaultPageSize = 12;

原始源代码:https ://sap.github.io/cloud-commerce-spartacus-storefront/injectables/ProductListComponentService.html#source

4

1 回答 1

0

只是为了更清楚起见,您创建了 aCustomProductListComponent和 a CustomProductListComponentService,它们的源代码与原始源代码相同,对吗?如果是,它应该可以工作 ootb,正如您所提到的,将 defaultPageSize 的值修改为 12。

我能想到的唯一一件事是您可以如何通过在 queryParams 上配置 Spartacus 来满足您的需求。如果是这样,您可以查看 中的函数getCriteriaFromRoute,该函数ProductListComponentService表示如果存在则使用 queryParams 的值,如果不存在则使用默认值。

希望这可以帮助

于 2020-03-24T21:08:03.027 回答