Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 38 lines (29 sloc) 1.526 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'

class AccessoriesExtension < Spree::Extension
  version "1.0"
  description "Add Accessories to Products"
  url "http://yourwebsite.com/spree_accessories"

  def activate
    # admin.tabs.add "Spree Accessories", "/admin/spree_accessories", :after => "Layouts", :visibility => [:all]
    
    Product.class_eval do
      has_many :paint_colors
      has_many :kits, :source=> :product, :through => :spare_parts, :select=> "DISTINCT product_id,products.*"
      has_many_polymorphs :sps, :from => [:product_wrappers,:taxons], :through => :spare_parts, :rename_individual_collections=>true
      has_many_polymorphs :osps, :from => [:product_wrappers,:taxons], :through => :optional_spare_parts, :rename_individual_collections=>true

    end
    
# Taxon.class_eval do
# #has_many_polymorphs :linkables, :from => [:spare_parts], :through => :accessories
# end


    # register Accessories product tab
    Admin::BaseController.class_eval do
      before_filter :add_accessories_tab
      
      private
      def add_accessories_tab
        @product_admin_tabs << {:name => "Pieces détachés", :url => "selected_admin_product_spare_parts_url"}
        @product_admin_tabs << {:name => "Pieces détachés Optionelles", :url => "selected_admin_product_optional_spare_parts_url"}
        @product_admin_tabs << {:name => "Couleurs", :url => "selected_admin_product_paint_colors_url"}
      end
    end
 
  end
end
Something went wrong with that request. Please try again.