From fa3b84b71f6bef33e7aaf8a075261416306f4e15 Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Mon, 17 Jun 2024 21:58:07 +0500 Subject: [PATCH] 11987: add clone action --- app/controllers/admin/products_v3_controller.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/controllers/admin/products_v3_controller.rb b/app/controllers/admin/products_v3_controller.rb index 2954094d6d..8299884db0 100644 --- a/app/controllers/admin/products_v3_controller.rb +++ b/app/controllers/admin/products_v3_controller.rb @@ -68,6 +68,21 @@ module Admin end end + def clone + @product = Spree::Product.find(params[:id]) + @cloned_product = @product.duplicate + @product_index = params[:product_index].to_i + 1 + status = @cloned_product.save ? :ok : :internal_server_error + + @producer_options = producers + @category_options = categories + @tax_category_options = tax_category_options + + respond_with do |format| + format.turbo_stream { render :clone, status: } + end + end + def index_url(params) "/admin/products?#{params.to_query}" # todo: fix routing so this can be automaticly generated end