I am new to shopify and I am trying to show the products from a collection.
I made a section in sections and used shopify schema to display this setting.
Only the header and description is showing in the page.
How can I display all the products from the chosen collection in the page ? I’ve search the web all day for an answer.
This is the schema I have.
Hope someone can help me ,thank you.
<h3>{{ section.settings.title }}</h3>
<p>{{ section.settings.column_richtext }}</p>
<a href="{{ section.settings.collection}}"></a>
{{ section.settings.collection | products}}
{% schema %}
{
"name": "Collection list 2",
"class": "index-section",
"max_blocks": 3,
"settings": [
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Collection list 2"
},
{
"type": "richtext",
"id": "column_richtext",
"label": "Short Description",
"default": "<p></p>"
},
{
"id": "collection",
"type": "collection",
"label": "Chose a collection"
},
{
"type": "range",
"id": "grid",
"label": "Collections per row",
"min": 2,
"max": 4,
"step": 1,
"default": 3
}
],
"blocks": [
{
"type": "collection",
"name": "Collection 2",
"settings": [
{
"type": "collection",
"id": "collection2",
"label": "Collection 2"
}
]
}
],
"presets": [
{
"name": "Collection list 2",
"category": "Collection",
"blocks": [
{
"type": "collection"
},
{
"type": "collection"
},
{
"type": "collection"
}
]
}
]
}
{% endschema %}
2
Answers
Use this to access products:
You cannot paginate the
collection
object unless you’re on the collection page. Usingfor
loop as per the example above I think you can get only 50 products.here is section code add create new section and add into related template