From 00cac067b7062d8b9e17b3a47207326cb23cf7c0 Mon Sep 17 00:00:00 2001 From: Beber Date: Wed, 8 Mar 2023 18:16:17 +0100 Subject: [PATCH] Duplicate master prices on product duplication Until v3.2.3 duplicating a product duplicated the price. Since v3.2.4 the product duplication does not duplicate the price. Looks like it comes from the PR #4639 :/ To fix it we duplicate all of the master prices on the new_product. --- core/lib/spree/core/product_duplicator.rb | 2 +- core/spec/models/spree/product_duplicator_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/spree/core/product_duplicator.rb b/core/lib/spree/core/product_duplicator.rb index f2ba0d9383b..882592a3596 100644 --- a/core/lib/spree/core/product_duplicator.rb +++ b/core/lib/spree/core/product_duplicator.rb @@ -45,7 +45,7 @@ def duplicate_master new_master.sku = "COPY OF #{master.sku}" new_master.deleted_at = nil new_master.images = master.images.map { |image| duplicate_image image } if @include_images - new_master.price = master.price + new_master.prices = master.prices.map(&:dup) end end diff --git a/core/spec/models/spree/product_duplicator_spec.rb b/core/spec/models/spree/product_duplicator_spec.rb index 7965b556b3c..e5720c0642a 100644 --- a/core/spec/models/spree/product_duplicator_spec.rb +++ b/core/spec/models/spree/product_duplicator_spec.rb @@ -61,6 +61,10 @@ module Spree expect(new_product.name).to eql "COPY OF #{product.name}" end + it "will set the same price" do + expect(new_product.reload.price).to eql product.price + end + it "will set an unique sku" do expect(new_product.sku).to include "COPY OF SKU" end