Search code examples
paginationspartacus-storefront

How do I change the default number of products in pagination on Spartacus product listing page?


Pagination on the Spartacus Product Listing Page also pagines 10 products by default.

I want PLP to have 24 products in paging. I customized the OCC / search service in Java and I see pageSize = 12 under Network in the browser, but the page is still pagination with 10.

enter image description here

When customizing the ProductListComponentService default file, the SORT operation on the page does not work.

How can I change the default number of products to be displayed on a page when paging.

Is there a structure like infinite scrolling? view: { infiniteScroll: { active: false, productLimit: 500, showMoreButton: false, }, },


Solution

  • There is no configurations for listing yet. In order to change the number of results I did the following:

    I extended ProductListComponentService and I was able to override the defaultPageSize property to get 24 products. After doing that the sorting was still functional.

    import { Injectable } from '@angular/core';
    import { ProductListComponentService } from '@spartacus/storefront';
    
    @Injectable({ providedIn: 'root' })
    export class MyProductListComponentService extends ProductListComponentService {
      defaultPageSize = 24;
    }
    
    

    In my app.module.ts:

    [...]
    providers: [{ provide: ProductListComponentService, useClass: MyProductListComponentService }],