Skip to content

Commit

Permalink
Duplicate master prices on product duplication
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 00cac06)
  • Loading branch information
Roddoric committed Mar 10, 2023
1 parent 64891b2 commit cd49002
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/lib/spree/core/product_duplicator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions core/spec/models/spree/product_duplicator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd49002

Please sign in to comment.