solidusio / solidus

🛒 Solidus, the open-source eCommerce framework for industry trailblazers.
https://solidus.io
Other
5.02k stars 1.29k forks source link

only one taxon_id and option_type_id possible when creating product #2791

Closed hefan closed 5 years ago

hefan commented 6 years ago

When you create a product and try to add more than one taxon_id or more than one option_type_id only the first one is saved.

During Update it works as it should.

Steps to reproduce

Create a new product and add more than one option_type_id or taxon_id to it. Click Create.

Expected behavior

The new Product should be created with more than one option type or taxon assigned

Actual behavior

Only the first option type or taxon is assigned. you need to assign the rest by updating the product again.

System configuration

Solidus Version: v2.6.0

Extensions in use:

Possible Solution

Just Split the taxon_ids and option_type_ids params similar like in the update function: https://github.com/solidusio/solidus/blob/master/backend/app/controllers/spree/admin/products_controller.rb

Something like:

before_action :split_params, only: [:create]

  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
jacobherrington commented 6 years ago

I am able to replicate this issue - planning on taking a look at it later today.

jacobherrington commented 6 years ago

Fix for this in #2840 pending review.

jacobherrington commented 5 years ago

@kennyadsl can this issue be closed now that you have merged #2840?

kennyadsl commented 5 years ago

Sure, thanks for pointing out!