I'm trying to get a count of all products uploaded in the last 30 days per collection

I'm trying to get a count of all products uploaded in the last 30 days per collection

kruttika
Shopify Partner
4 0 0

I have this partially working code but it's timing out with this error; 

The rendered liquid was too large or had too many assignments

 

Is there any better way of doing this?

 

 

 

 

 

{% assign c_date = "today" | date: '%Y-%m-%d' | minus: 30 %}


{% for getCollectionData_item in getCollectionData %}
{% if getCollectionData_item.booleanCategory.value %}
{{getCollectionData_item.title}} - {{getCollectionData_item.productsCount.count}}-

{% for getCollectionData_item in getCollectionData %}
{%assign activeCount=0%}
{% for products_item in getCollectionData_item.products %}
{% if products_item.createdAt >c_date%}
{% assign activeCount = activeCount| plus: 1 %}
{% endif %}
{{activeCount}}
{% endfor %}
{% endfor %}

{% endif %}
{% endfor %}

 

 

 

 

 

Replies 6 (6)

Amelia95
Tourist
6 0 1

Yes and also, Your Liquid code will generate the error "The rendered liquid was too large or had too many assignments" if it processes too much data at once. The Shopify Admin API or ShopifyQL are the better options for this operation because Liquid is a server-side templating language that has restrictions on loops and assignments.


kruttika
Shopify Partner
4 0 0

how can I use shopifyQL? 

Amelia95
Tourist
6 0 1

ShopifyQL Notebooks can be used to study data within Shopify.

How ShopifyQL Is Used in Notebooks:
Go to Admin on Shopify. Click "Create a Notebook" after selecting "Analytics" > "Notebooks"
Use the notebook editor's ShopifyQL queries.
or you can query Shopify data via API but You must have access to the ShopifyQL Data API and Shopify Plus in order to query Shopify data via API.

How to Utilize the ShopifyQL API:
Turn on access to the ShopifyQL API.
Enter Shopify Admin.
Select Apps > Create Apps.
Make a brand-new, unique application.
Expand the scope of the ShopifyQL API under permissions.
Submit a Request to the API
To retrieve structured data, submit a request to the GraphQL API. 
And also Use ShopifyQL in Notebooks for Analytics & Reports (no code required).
Use the ShopifyQL Data API for APIs and automations (Shopify Plus is required).

kruttika
Shopify Partner
4 0 0

Anny way to do this in flow?

Amelia95
Tourist
6 0 1

No, Shopify Flow cannot directly execute ShopifyQL queries because Flow is an automation tool, not a data analysis or query engine.

If your goal is automation without custom coding, consider:

  • Triggering Flow based on events (e.g., new order, low stock).
  • Sending Flow actions to Google Sheets or another service where you process ShopifyQL separately.

If you're using Shopify Plus and want deep automation, combining Shopify Flow plus a custom app is the best way to go.

kruttika
Shopify Partner
4 0 0

Im actually unable to see any of these options in Shopify for me.