{% set currentVendor = market.vendors.getCurrentVendor() %} {% set page = page ?? 1 %} {% set sort = sort ?? 'postDate' %} {% set sortDir = sortDir ?? 'desc' %} {% set limit = limit ?? 10 %} {% if limit > 100 %}{% set limit = 100 %}{% endif %} {% set query = query ?? '' %} {% set status = status ?? '' %} {% do sprig.pushUrl('?page='~page~'&sort='~sort~'&sortDir='~sortDir~'&query='~query) %} {% set productsQuery = craft.products .status(status) .limit(limit) .search(query) .orderBy(sort~' '~sortDir) .relatedTo({ 'targetElement': currentVendor.id, 'field': 'vendor' }) %} {% set pageInfo = sprig.paginate(productsQuery, page) %} {% set products = pageInfo.pageResults %} {% set statusMap = { live: 'bg-green-100 text-green-800', pending: 'bg-orange-100 text-orange-800', expired: 'bg-red-100 text-red-800', disabled: 'bg-gray-100 text-gray-800', } %} {% if selectedIds is not defined %} {% set selectedIds = [] %} {% endif %} {% if selectedIds is defined and selectedIds is not iterable %} {% set selectedIds = selectedIds|split(',') %} {% endif %} {% set selectedIds = selectedIds|filter|unique %} {% if successfulNotice is defined %} {% do craft.app.session.setNotice(successfulNotice) %} {% do sprig.redirect('/market/products') %} {% endif %} {# Header #}

{{ 'Products'|t('market') }}

{# Actions #}
{# Action menu for selected rows #} {% if selectedIds %}
{% endif %} {# New product #}
{# Search and filters #}
{# Search #}
{# Heroicon name: search #}
{# Status #}
{# Limit #}
{# Results container #}
{% if products %} {# Results table #}
{% for product in products %} {% set productUrl = url('market/products/'~product.type.handle~'/'~product.id~'-'~product.slug) %} {% endfor %}
Select all products {% if selectedIds|length >= 1 and products|length != selectedIds|length %} {% endif %} Status
{% set img = product.primaryImage[0] ?? null %} {% if img %} {% else %} {% endif %}
{{ product.title }}
{{ product.status|title }} {{ product.defaultSku }} {{ product.defaultPrice|currency(null, [], [], true) }} {{ product.postDate|datetime('short') }}
{# Pagination #} {% include '_market/_includes/pagination' with { itemType: 'products', vals: { 'sort': sort, 'sort-dir': sortDir } } %} {% elseif query or status %} {# No results #}
{# Heroicon name: emoji-sad #}

Oh no!

{% if query %}

We couldn’t find anything for “{{ query }}”, try being less specific or using different keywords.

You can search for most things including product titles, descriptions, SKUs and other text content you have added.

{% elseif status %}

We couldn’t find any {{ status }} products.

{% endif %}
{% else %} {# No products at all yet #}
{# Heroicon name: light-bulb #}

Nothing here …

You don’t have any products yet, go ahead and add your very first one!

{% for productType in craft.commerce.productTypes.getEditableProductTypes() %} Create a {{ productType.name }} product {% endfor %}
{% endif %}