Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Display collections in collection-list view

Mira Szewczyk69960a27a663
diff --git a/saleor/dashboard/collection/views.py b/saleor/dashboard/collection/views.py
index 6e6929c166..ac37cbc87d 100644
--- a/saleor/dashboard/collection/views.py
+++ b/saleor/dashboard/collection/views.py
@@ -11,7 +11,7 @@ from .forms import CollectionForm
@staff_member_required
def collection_list(request):
- collections = Collection.objects.all()
+ collections = Collection.objects.prefetch_related('products').all()
collections = get_paginator_items(collections, 30, request.GET.get('page'))
ctx = {'collections': collections}
return TemplateResponse(request,
diff --git a/templates/dashboard/collection/list.html b/templates/dashboard/collection/list.html
index 141487a327..2877619f3b 100644
--- a/templates/dashboard/collection/list.html
+++ b/templates/dashboard/collection/list.html
@@ -27,8 +27,20 @@
<div class="row">
<div class="col s12">
{% if collections %}
- {% for collection in collections %}
- {% endfor %}
+ <ul class="collection list">
+ {% for collection in collections %}
+ <li class="collection-item list-item list-item--two-lines">
+ <a class="list-item-name" href="#">
+ {{ collection }}
+ </a>
+ <p class="list-item-desc">
+ <span>
+ {% trans "Products in collection:" %} {{ collection.products.count }}
+ </span>
+ </p>
+ </li>
+ {% endfor %}
+ </ul>
{% else %}
<p>{% trans "No collections" %}</p>
{% endif %}