I've been developing a website for my company g7g20.com and we are interested in creating a most popular articles or top 10 articles panel and was wondering if there was a way of accessing the analytics to display this?
We already have a latest and related and just want to mix it up a bit. Any thoughts would be most welcome.
The following code will give you all products which sold more than 5 units during the last 100 days.
{% assign date = globals.site.dateNow | date_add: -100, "day" -%}
{module_data resource="products" version="v3" fields="id" limit="100" where="\{'orders.units':\{'$gt':'5'\},'orders.createDate':\{'$gt':'{{date}}'\}\}" collection="units"}
<pre>{{units|json}}</pre>
You can then use the product IDs like so and render the products
{% for item in units.items -%}
{module_data resource="catalogproducts" version="v3" limit="1" fields="productId,catalogueId" where="\{'product.id':'{{item.id}}'\}" order="catalogueId" collection="products"}
{% for item in products.items -%}
{% assign CATID = {{item.catalogueId}} -%}
{% assign PROID = {{item.productId}} -%}
{module_product,{{CATID}},{{PROID}}}
{% endfor -%}
{% endfor -%}