bigcartel / dugway

Easily build and test Big Cartel themes.
https://developers.bigcartel.com/api/themes
MIT License
149 stars 22 forks source link

Products Per Page Setting Not Working #139

Closed kmgdevelopment closed 8 years ago

kmgdevelopment commented 8 years ago

I'm trying to set the products per page setting, but it doesn't seem to be working. My products template in dugway just shows all the products at once. I put this in my .dugway.json file:

  "store": {
     "subdomain": "mystoresubdomain"
  },
  "customization": {
    "products_per_page": 9
  }

And restarted dugway server, but nothing. I also tried:

"store": {
     "subdomain": "mystoresubdomain"
  },
  "customization": {
    "options": {
      "products_per_page": 9
    }
  }

The weird thing is the default setting in settings.json is also 9, so I don't see why it's outputting wrong.

nickendle commented 8 years ago

@kgrote hmm, I'm able to get this to work without any problems by using this code in my .dugway.json file:

{
  "store": {
    "subdomain": "nickswoodshop"
  },
  "customization": {
    "products_per_page": 4
  }
}

You might need to make sure that your Products page has the correct code to use the theme setting - here's one example:

{% paginate products from products.current by theme.products_per_page %}
  {% if products != blank %}
    <ul class="products">
      {% for product in products %}
      <li class="{{ product.css_class }}">
        <a href="{{ product.url }}">
          <img alt="Image of {{ product.name | escape }}" src="{{ product.image | product_image_url }}">
          <h4>{{ product.name }}</h4>
        </a>
      </li>
      {% endfor %}
    </ul>
    {{ paginate | default_pagination }}
  {% else %}
    <p>No products found.</p>
  {% endif %}
{% endpaginate %}
kmgdevelopment commented 8 years ago

Yup, you're right. My product logic wasn't correct. It was working on the production site though, so it was confusing. Thanks.