宝石信息:
请求:
parameters = {fields: 'id,title,url,handle', page: params[:page] || 1, limit: 5}
parameters = parameters.merge(title: params[:title]) if params[:title].present?
@products = ShopifyAPI::Product.find(:all, params: parameters)
问题:
请求title
结果的WITH过滤器不包括total_count
。
因此pagination
不起作用,在视图中也不显示。
<%= paginate @items, :pagination_class => 'pagination-centered', params: {title: params[:title], page: params[:page] || 1} %>
我最终为每个请求传递了最大限制250。然后,我将对集合使用#fetch_next_page
方法。
products = ShopifyAPI::Product.find(:all, params: { limit: 250 }
# do something with the products
products.fetch_next_page if products.next_page?
这将继续以250为批次提取记录,直到没有下一页为止,这意味着它是最后一页。