From 4ee2e7154335ea508c8a73f7a314075ed73e46b4 Mon Sep 17 00:00:00 2001 From: Miguel Sancho Fernandez Date: Sat, 8 Apr 2017 14:08:07 -0700 Subject: [PATCH 1/3] removed has_many :orders, is included in original The original Store definition model in Spree has the has_many relation with orders, check the next line https://github.com/spree/spree/blob/master/core/app/models/spree/store.rb#L3 --- app/models/spree/store_decorator.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/spree/store_decorator.rb b/app/models/spree/store_decorator.rb index 710d8b6b..e567b4e2 100644 --- a/app/models/spree/store_decorator.rb +++ b/app/models/spree/store_decorator.rb @@ -2,8 +2,6 @@ module Spree Store.class_eval do has_and_belongs_to_many :products, join_table: 'spree_products_stores' has_many :taxonomies - has_many :orders - has_many :store_payment_methods has_many :payment_methods, through: :store_payment_methods From 87c130e03ceaba93976ece2b52ca7c82f67293f2 Mon Sep 17 00:00:00 2001 From: Arnaud Augier Date: Tue, 20 Sep 2016 18:16:50 +0200 Subject: [PATCH 2/3] allow multiple taxons in product Allow to affect multiple taxons in product when using spree-multi-domain : see #148 --- .../spree/admin/products_controller_decorator.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/spree/admin/products_controller_decorator.rb b/app/controllers/spree/admin/products_controller_decorator.rb index b5903c5d..2e8ce37c 100644 --- a/app/controllers/spree/admin/products_controller_decorator.rb +++ b/app/controllers/spree/admin/products_controller_decorator.rb @@ -1,17 +1,18 @@ Spree::Admin::ProductsController.class_eval do update.before :set_stores + before_action :find_stores, only: [:update] - def update + private + + def set_stores + @product.store_ids = nil unless params[:product].key? :store_ids + end + + def find_stores store_ids = params[:product][:store_ids] if store_ids.present? params[:product][:store_ids] = store_ids.split(',') end - super end - private - - def set_stores - @product.store_ids = nil unless params[:product].key? :store_ids - end end From 16857297bb6890e41fb89fe50c0e6815b4f03e6d Mon Sep 17 00:00:00 2001 From: Miguel Sancho Date: Mon, 17 Apr 2017 21:13:31 -0700 Subject: [PATCH 3/3] removed fromend in spree_muti_domain --- lib/spree_multi_domain/engine.rb | 42 ------------------- .../multi_domain_helpers.rb | 2 +- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/lib/spree_multi_domain/engine.rb b/lib/spree_multi_domain/engine.rb index 54457ac5..a92d5afc 100644 --- a/lib/spree_multi_domain/engine.rb +++ b/lib/spree_multi_domain/engine.rb @@ -11,52 +11,10 @@ def self.activate end end - Spree::Config.searcher_class = Spree::Search::MultiDomain - ApplicationController.send :include, SpreeMultiDomain::MultiDomainHelpers end config.to_prepare &method(:activate).to_proc - initializer "templates with dynamic layouts" do |app| - ActionView::TemplateRenderer.class_eval do - def find_layout_with_multi_store(layout, locals, *formats) - store_layout = layout - - if @view.respond_to?(:current_store) && @view.current_store && !@view.controller.is_a?(Spree::Admin::BaseController) - store_layout = if layout.is_a?(String) - layout.gsub("layouts/", "layouts/#{@view.current_store.code}/") - else - layout.call.try(:gsub, "layouts/", "layouts/#{@view.current_store.code}/") - end - end - - begin - find_layout_without_multi_store(store_layout, locals, *formats) - rescue ::ActionView::MissingTemplate - find_layout_without_multi_store(layout, locals, *formats) - end - end - - alias_method_chain :find_layout, :multi_store - end - end - - initializer "current order decoration" do |app| - require 'spree/core/controller_helpers/order' - ::Spree::Core::ControllerHelpers::Order.module_eval do - def current_order_with_multi_domain(options = {}) - options[:create_order_if_necessary] ||= false - current_order_without_multi_domain(options) - - if @current_order and current_store and @current_order.store.blank? - @current_order.update_attribute(:store_id, current_store.id) - end - - @current_order - end - alias_method_chain :current_order, :multi_domain - end - end initializer 'spree.promo.register.promotions.rules' do |app| app.config.spree.promotions.rules << Spree::Promotion::Rules::Store diff --git a/lib/spree_multi_domain/multi_domain_helpers.rb b/lib/spree_multi_domain/multi_domain_helpers.rb index ad9af006..1f76d577 100644 --- a/lib/spree_multi_domain/multi_domain_helpers.rb +++ b/lib/spree_multi_domain/multi_domain_helpers.rb @@ -20,7 +20,7 @@ def get_taxonomies end def add_current_store_id_to_params - params[:current_store_id] = current_store.try(:id) + # params[:current_store_id] = current_store.try(:id) end end end