Theme app extension help

clumsyChef
Shopify Partner
1 0 0

Hi,

I am developing an app for which I was trying to fetch the products and sort them on the basis of price, and created time. So I created a collection template and made the request to it. I named this 'templates/collection.test.liquid'.

 

{% layout none %}
{% capture productsJson %}
  {% paginate collection.products by 25 %}
    {{ collection.products | json }}
  {% endpaginate %}
{% endcapture %}
{{ productsJson }}

 

 Then to get products sorted by price descending I would make a fetch request from shop to this link

 

https://some-kind-of-example.myshopify.com/collections/all?view=test&sort_by=price-descending

 

and I will get the JSON data.

Now the problem is when app will be created I had to create this template for user. But I can't as it is not allowed.

Can I do the same thing with theme app extension ?

I have tried to get the liquid code in this way

 

{% assign allProducts = collection["all"].products %}
{% for product in allProducts %}
{{ product.title }}
{% endfor %}

 

but this code only fetches the first 50 products. And if try to sort them, it will just do the sorting in those products.
I need help regarding this.

Replies 0 (0)