Forum

Thread tagged as: Question, Shop

Paginate perch_shop_products() result

Is it possible to paginate the results of perch_shop_products() the same way you can for perch_content_custom() ?

Hamish Irving

Hamish Irving 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes - what problem are you seeing?

I'm not seeing any pagination with the following function:

perch_shop_products([
  'template' => 'product-grid-item.html',
  'category' => $filters,
  'category-match' => 'all',
  'paginate' => true,
  'count' => 5,
  ]); 

I wasn't sure where the pagination template needed to live but I copied it to shop > pagination > default.html

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you added pagination controls to your product-grid-item.html template?

Ah, I misunderstood how the template worked - I thought it could simply be specified using 'page-link-template'=>'pagination/default.html', but I've now added

<perch:after>
  <perch:template path="pagination/default.html" rescope="parent" />
</perch:after>

to my product-grid-item.html template and it works, thanks!