Disable sorting by user-defined product category order

This commit is contained in:
Matt-Yorkley
2023-08-09 13:11:32 +01:00
committed by Gaetan Craig-Riou
parent 3f2a5786bd
commit 2743a8183d
5 changed files with 6 additions and 11 deletions

View File

@@ -74,12 +74,6 @@ class ProductsRenderer
.preferred_shopfront_producer_order
.split(",").map { |id| "spree_products.supplier_id=#{id} DESC" }
.join(", ") + ", spree_products.name ASC, spree_products.id ASC"
elsif distributor.preferred_shopfront_product_sorting_method == "by_category" &&
distributor.preferred_shopfront_taxon_order.present?
distributor
.preferred_shopfront_taxon_order
.split(",").map { |id| "spree_products.primary_taxon_id=#{id} DESC" }
.join(", ") + ", spree_products.name ASC, spree_products.id ASC"
else
"spree_products.name ASC, spree_products.id"
end

View File

@@ -1249,6 +1249,7 @@ en:
open_date: "Open Date"
close_date: "Close Date"
display_ordering_in_shopfront: "Display ordering in shopfront:"
shopfront_sort_by_product: "By product"
shopfront_sort_by_category: "By category"
shopfront_sort_by_producer: "By producer"
shopfront_sort_by_category_placeholder: "Category"

View File

@@ -280,13 +280,13 @@ module Api
exchange.variants << product8.variants.first
end
it "displays products in new order" do
xit "displays products in new order" do
api_get :products, id: order_cycle.id, distributor: distributor.id
expect(product_ids).to eq [product7.id, product8.id, product2.id, product3.id, product5.id,
product6.id, product1.id]
end
it "displays products in correct order across multiple pages" do
xit "displays products in correct order across multiple pages" do
api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 3
expect(product_ids).to eq [product7.id, product8.id, product2.id]

View File

@@ -39,7 +39,7 @@ describe ProductsRenderer do
end
describe "sorting" do
it "sorts products by the distributor's preferred taxon list" do
xit "sorts products by the distributor's preferred taxon list" do
allow(distributor)
.to receive(:preferred_shopfront_taxon_order) { "#{cakes.id},#{fruits.id}" }
products = products_renderer.send(:products)
@@ -106,7 +106,7 @@ describe ProductsRenderer do
expect(products).to eq([product_apples, product_cherries])
end
it "filters products with property when sorting is enabled" do
xit "filters products with property when sorting is enabled" do
allow(distributor).to receive(:preferred_shopfront_taxon_order) {
"#{fruits.id},#{cakes.id}"
}

View File

@@ -536,7 +536,7 @@ describe '
.to eq('Enterprise "First Distributor" has been successfully updated!')
end
it "sets the preference correctly" do
xit "sets the preference correctly" do
expect(distributor1.preferred_shopfront_product_sorting_method).to eql("by_category")
expect(distributor1.preferred_shopfront_taxon_order).to eql(taxon.id.to_s)
end