Skip to content

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

Always pass images as a static list

Artur Smęte44f4845bbb6
diff --git a/saleor/product/utils.py b/saleor/product/utils.py
index 8194e553cd..c3c7efccd8 100644
--- a/saleor/product/utils.py
+++ b/saleor/product/utils.py
@@ -17,3 +17,10 @@ def products_with_details(user):
'variants__variant_images__image',
'attributes__values')
return products
+
+
+def get_product_images(product):
+ """
+ Returns list of product images that will be placed in product gallery
+ """
+ return list(product.images.all())
diff --git a/saleor/product/views.py b/saleor/product/views.py
index 3e994f0b38..6b4f3b44c5 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -11,7 +11,7 @@ from ..cart.decorators import get_cart_from_request
from ..core.utils import get_paginator_items, to_local_currency
from .forms import get_form_class_for_product
from .models import Category
-from .utils import products_with_details
+from .utils import products_with_details, get_product_images
def product_details(request, slug, product_id):
@@ -73,6 +73,7 @@ def product_details(request, slug, product_id):
template_name = 'product/details_%s.html' % (
type(product).__name__.lower(),)
templates = [template_name, 'product/details.html']
+ product_images = get_product_images(product)
return TemplateResponse(
request, templates,
{
@@ -82,7 +83,8 @@ def product_details(request, slug, product_id):
'local_price_range': local_price_range,
'price_range': price_range,
'product': product,
- 'undiscounted_price_range': undiscounted_price_range})
+ 'undiscounted_price_range': undiscounted_price_range,
+ 'product_images': product_images})
def category_index(request, path, category_id):