Ensure results in #products_relation are DISTINCT

This commit is contained in:
Matt-Yorkley
2019-10-30 17:14:20 +00:00
parent 6d50176e6b
commit f8209ac7d5
2 changed files with 4 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ class OrderCycleDistributedProducts
end
def products_relation
Spree::Product.where(id: stocked_products)
Spree::Product.where(id: stocked_products).group("spree_products.id")
end
def variants_relation

View File

@@ -63,10 +63,10 @@ class ProductsRenderer
if distributor.preferred_shopfront_taxon_order.present?
distributor
.preferred_shopfront_taxon_order
.split(",").map { |id| "primary_taxon_id=#{id} DESC" }
.join(",") + ", name ASC"
.split(",").map { |id| "spree_products.primary_taxon_id=#{id} DESC" }
.join(", ") + ", spree_products.name ASC"
else
"name ASC"
"spree_products.name ASC"
end
end