From 8002ab4a639bcebfe3d821d839eb69c013b82bdc Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Thu, 8 Aug 2024 09:26:12 -0700 Subject: [PATCH] Add before action to handle option type params As reported in #5751, the new admin UI has a bug with the option type selectors: only one option type can be added. We narrowed this down to an issue handling option type params in the new admin products controller. We noticed legacy controller contains a before action to handle the incoming option type params, but the new one did not. Re-adding the before action solves the bug. This is required because the form input for option types contains comma separated values within a string: `` Co-authored-by: An Stewart --- .../controllers/solidus_admin/products_controller.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/admin/app/controllers/solidus_admin/products_controller.rb b/admin/app/controllers/solidus_admin/products_controller.rb index a085ef0d41c..094c2c6ab08 100644 --- a/admin/app/controllers/solidus_admin/products_controller.rb +++ b/admin/app/controllers/solidus_admin/products_controller.rb @@ -11,6 +11,8 @@ class ProductsController < SolidusAdmin::BaseController search_scope(:in_stock) { _1.where(id: Spree::Variant.in_stock.distinct.select(:product_id)) } search_scope(:out_of_stock) { _1.where.not(id: Spree::Variant.in_stock.distinct.select(:product_id)) } + before_action :split_params, only: [:update] + def index products = apply_search_to( Spree::Product.includes(:master, :variants), @@ -98,5 +100,14 @@ def activate flash[:notice] = t('.success') redirect_to products_path, status: :see_other end + + def split_params + if params[:product][:taxon_ids].present? + params[:product][:taxon_ids] = params[:product][:taxon_ids].split(',') + end + if params[:product][:option_type_ids].present? + params[:product][:option_type_ids] = params[:product][:option_type_ids].split(',') + end + end end end