Skip to content

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

Display variant information

Mira Szewczyk7657d0658f26
diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.py
index 4c5c9de0e9..2ead4a1149 100644
--- a/saleor/dashboard/product/views.py
+++ b/saleor/dashboard/product/views.py
@@ -135,15 +135,14 @@ def product_create(request, class_pk):
@staff_member_required
def product_detail(request, pk):
- products = Product.objects.select_related('product_class').prefetch_related(
- 'product_class__product_attributes__values', 'categories').all()
+ products = Product.objects.prefetch_related('variants').all()
product = get_object_or_404(products, pk=pk)
- attributes = get_product_attributes_data(product)
+ variants = product.variants.all()
availability = get_availability(product)
sale_price = availability.price_range
gross_price_range = product.get_gross_price_range()
- ctx = {'product': product, 'attributes': attributes,
- 'sale_price': sale_price, 'gross_price_range': gross_price_range}
+ ctx = {'product': product, 'sale_price': sale_price,
+ 'gross_price_range': gross_price_range, 'variants': variants}
return TemplateResponse(
request, 'dashboard/product/product_detail.html', ctx)
diff --git a/templates/dashboard/product/product_detail.html b/templates/dashboard/product/product_detail.html
index f20ca37237..bf4e1df279 100644
--- a/templates/dashboard/product/product_detail.html
+++ b/templates/dashboard/product/product_detail.html
@@ -100,6 +100,29 @@
<div class="card">
<div class="card-content">
<span class="card-title">{% trans "Variant" %}</span>
+ <table>
+ <thead>
+ <tr>
+ <th>{% trans "SKU" %}</th>
+ <th>{% trans "Name" %}</th>
+ <th>{% trans "Status" %}</th>
+ <th>{% trans "Price" %}</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for variant in variants %}
+ <tr>
+ <td>{{ variant.sku }}</td>
+ <td>{{ variant }}</td>
+ <td></td>
+ <td>{% gross variant.get_price_per_item %}</td>
+ <td><a href="{% url 'dashboard:variant-update' product_pk=product.pk variant_pk=variant.pk %}" class="btn waves-effect waves-light">{% trans "Edit" %}</a></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ <a href="{% url 'dashboard:variant-add' product_pk=product.pk %}" class="btn waves-effect waves-light">{% trans "Add variant" %}</a>
</div>
</div>
</div>