1

I'm using the following code on a category listing page to list the sub-categories that contain products:

{% set entryIds = craft.commerce.products.ids() %}
{% if category is defined %}
    {% set currentCategory = craft.request.getSegment(2) %}
    {% set categories = craft.categories.descendantOf(category).relatedTo({ sourceElement: entryIds }).groupId(1).order('title asc').find() %}
{% else %}
    {% set categories = craft.categories.relatedTo({ sourceElement: entryIds }).groupId(1).level(1).order('title asc').find() %}
{% endif %}

What I'm experiencing is that craft.commerce.products.ids() only returns the ids for products that have a Post Date in the current month. This is not ideal since some products might've been added months ago but still remain active on the site.

Is this normal behaviour for craft.commerce.products.ids() or is this a possible bug ? Any ideas on a workaround ?

3

Are you sure you're not simply hitting the default limit which is 100?

Try this

{% set entryIds = craft.commerce.products({limit: null}).ids() %}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.