Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Partial view with related products to display on product details page
Mira Szewczyk7ff0947a8e39
diff --git a/saleor/product/urls.py b/saleor/product/urls.pyindex 792a3322de..fbaa6ef8a0 100644--- a/saleor/product/urls.py+++ b/saleor/product/urls.py@@ -10,4 +10,6 @@ urlpatterns = [views.category_index, name='category'),url(r'(?P<slug>[a-z0-9-_]+?)-(?P<product_id>[0-9]+)/add/$',views.product_add_to_cart, name="add-to-cart"),+ url(r'^(?P<product_id>[0-9]+)/$',+ views.products_from_collections, name="from_collections"),]diff --git a/saleor/product/views.py b/saleor/product/views.pyindex b9913327fa..0f4aee6d27 100644--- a/saleor/product/views.py+++ b/saleor/product/views.py@@ -136,4 +136,19 @@ def category_index(request, path, category_id):=======return TemplateResponse(request, 'category/index.html',{'category': category})+<<<<<<< HEAD>>>>>>> Remove display collection view+=======+++def products_from_collections(request, product_id):+ related_products = Product.objects.prefetch_related(+ 'collections', 'images').filter(+ collections__products__id=product_id).exclude(+ id=product_id).distinct()+ products = products_with_availability(related_products,+ discounts=request.discounts,+ local_currency=request.currency)+ ctx = {'products': products}+ return TemplateResponse(request, 'product/_product_collections.html', ctx)+>>>>>>> Partial view with related products to display on product details pagediff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.jsindex 6813ee14e3..8d2f4cd8cc 100644--- a/saleor/static/js/storefront.js+++ b/saleor/static/js/storefront.js@@ -11,3 +11,6 @@ import './components/address-form';import './components/password-input';import './components/styleguide';import './components/misc';++let $collections = $('#collections');+$collections.load($collections.data('url'));diff --git a/templates/product/_product_collections.html b/templates/product/_product_collections.htmlnew file mode 100644index 0000000000..8c023f85c1--- /dev/null+++ b/templates/product/_product_collections.html@@ -0,0 +1,3 @@+<div class="row">+ {% include 'category/_items.html' %}+</div>\ No newline at end of filediff --git a/templates/product/details.html b/templates/product/details.htmlindex b8f20e3621..58439c8517 100644--- a/templates/product/details.html+++ b/templates/product/details.html@@ -177,4 +177,7 @@</table></div></div>+ <div id="collections" data-url="{% url 'product:from_collections' product.id %}">++ </div>{% endblock content %}