Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spree::ProductDuplicator bug on price #4971

Conversation

Roddoric
Copy link
Contributor

@Roddoric Roddoric commented Mar 8, 2023

Summary

Created to support #4970

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 :/

The code looks like price is supposed to be copied:
Spree::ProductDuplicator#duplicate_master

    def duplicate_master
      master = product.master
      master.dup.tap do |new_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
      end
    end

To fix it I duplicated all of the master prices on the new_product.master.
Looks like it work for the test and for our app.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

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 solidusio#4639 :/

To fix it we duplicate all of the master prices on the new_product.
@Roddoric Roddoric force-pushed the duplicate-price-on-product-duplication branch from d58d896 to 00cac06 Compare March 9, 2023 10:05
@Roddoric Roddoric marked this pull request as ready for review March 9, 2023 10:23
@Roddoric Roddoric requested a review from a team as a code owner March 9, 2023 10:23
@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Merging #4971 (00cac06) into master (c09ead3) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4971   +/-   ##
=======================================
  Coverage   86.69%   86.69%           
=======================================
  Files         578      578           
  Lines       14685    14685           
=======================================
  Hits        12731    12731           
  Misses       1954     1954           
Impacted Files Coverage Δ
core/lib/spree/core/product_duplicator.rb 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, @Roddoric! 🎉

@kennyadsl kennyadsl added backport-v3.2 backport-v3.3 Backport this pull-request to v3.3 type:bug Error, flaw or fault labels Mar 9, 2023
@Roddoric
Copy link
Contributor Author

@kennyadsl it should also be back-ported to v3.1 as the version 3.1.9 is also concerned

@kennyadsl
Copy link
Member

@Roddoric you are right, done!

@github-actions
Copy link

💚 All backports created successfully

Status Branch Result
v3.2
v3.1
v3.3

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v3.3 Backport this pull-request to v3.3 changelog:solidus_core Changes to the solidus_core gem type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants