Class: Spree::Products::Duplicator
- Inherits:
-
Object
- Object
- Spree::Products::Duplicator
- Includes:
- ServiceModule::Base
- Defined in:
- app/services/spree/products/duplicator.rb
Instance Method Summary collapse
Methods included from ServiceModule::Base
Instance Method Details
#call(product:, include_images: true) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/spree/products/duplicator.rb', line 6 def call(product:, include_images: true) new_product = duplicate_product(product, include_images) # don't dup the actual variants, just the characterising types new_product.option_types = product.option_types if product.has_variants? # allow site to do some customization new_product.send(:duplicate_extra, product) if new_product.respond_to?(:duplicate_extra) new_product.save new_product.persisted? ? success(new_product) : failure(new_product, (new_product)) end |