LoginSignup
3
3

More than 5 years have passed since last update.

[Spree] 商品管理のオプションタイプ追加時の不具合

Posted at
  • Spreeで商品管理のオプションタイプを追加するとタイムアウトが発生する様になった
  • DBへの負荷が尋常では無く危険な状態
  • 調査してみたところオプションタイプを追加するときに全商品のレコードを更新(touch)している処理がある
  • touch処理は外しても問題が無さそうなので外した
  • 何か意図があって全件touchをしているのかもしれないので管理画面からupdateするときのみtouch処理をskipさせた
  • パッチを適用させたのはoption_types_controllerのみ

decorator

  • app/controllers/spree/option_types_controller_decorator.rb
Spree::Admin::OptionTypesController.class_eval do
  def update
    Spree::OptionType.skip_callback(:touch, :after, :touch_all_products)
    super
  end
end
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3