Class: Spree::Taxon
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::Taxon
- Includes:
- Core::ProductFilters, Core::S3Support
- Defined in:
- app/models/spree/taxon.rb
Instance Method Summary collapse
- #active_products ⇒ Object
-
#applicable_filters ⇒ Object
indicate which filters should be used for a taxon this method should be customized to your own site.
- #pretty_name ⇒ Object
-
#seo_title ⇒ Object
Return meta_title if set otherwise generates from root name and/or taxon name.
-
#set_permalink ⇒ Object
Creates permalink based on Stringex’s .to_url method.
-
#to_param ⇒ Object
For #2759.
Methods included from Core::ProductFilters
all_taxons, brand_filter, format_price, price_filter, selective_brand_filter, taxons_below
Instance Method Details
#active_products ⇒ Object
63 64 65 66 |
# File 'app/models/spree/taxon.rb', line 63 def active_products scope = products.active scope end |
#applicable_filters ⇒ Object
indicate which filters should be used for a taxon this method should be customized to your own site
30 31 32 33 34 35 36 37 38 |
# File 'app/models/spree/taxon.rb', line 30 def applicable_filters fs = [] # fs << ProductFilters.taxons_below(self) ## unless it's a root taxon? left open for demo purposes fs << Spree::Core::ProductFilters.price_filter if Spree::Core::ProductFilters.respond_to?(:price_filter) fs << Spree::Core::ProductFilters.brand_filter if Spree::Core::ProductFilters.respond_to?(:brand_filter) fs end |
#pretty_name ⇒ Object
68 69 70 71 72 73 |
# File 'app/models/spree/taxon.rb', line 68 def pretty_name ancestor_chain = self.ancestors.inject("") do |name, ancestor| name += "#{ancestor.name} -> " end ancestor_chain + "#{name}" end |
#seo_title ⇒ Object
Return meta_title if set otherwise generates from root name and/or taxon name
41 42 43 44 45 46 47 |
# File 'app/models/spree/taxon.rb', line 41 def seo_title if else root? ? name : "#{root.name} - #{name}" end end |
#set_permalink ⇒ Object
Creates permalink based on Stringex’s .to_url method
50 51 52 53 54 55 56 |
# File 'app/models/spree/taxon.rb', line 50 def set_permalink if parent.present? self.permalink = [parent.permalink, (permalink.blank? ? name.to_url : permalink.split('/').last)].join('/') else self.permalink = name.to_url if permalink.blank? end end |
#to_param ⇒ Object
For #2759
59 60 61 |
# File 'app/models/spree/taxon.rb', line 59 def to_param permalink end |