Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

removed has_many :orders, is included in original #165

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions app/controllers/spree/admin/products_controller_decorator.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions app/models/spree/store_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
42 changes: 0 additions & 42 deletions lib/spree_multi_domain/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 && [email protected]_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
Expand Down
2 changes: 1 addition & 1 deletion lib/spree_multi_domain/multi_domain_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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