Class: Spree::Taxon

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ProductFilters
Defined in:
app/models/spree/taxon.rb

Instance Method Summary collapse

Methods included from ProductFilters

all_taxons, brand_filter, price_filter, selective_brand_filter, taxons_below

Methods included from BaseHelper

#available_countries, #body_class, #breadcrumbs, #current_orders_product_count, #flash_messages, #format_price, #link_to_cart, #logo, #meta_data_tags, #order_subtotal, #seo_url, #taxons_tree, #todays_short_date, #variant_options, #yesterdays_short_date

Instance Method Details

#active_productsObject



41
42
43
44
45
# File 'app/models/spree/taxon.rb', line 41

def active_products
  scope = self.products.active
  scope = scope.on_hand unless Spree::Config[:show_zero_stock_products]
  scope
end

#applicable_filtersObject

indicate which filters should be used for a taxon this method should be customized to your own site



21
22
23
24
25
26
27
28
29
# File 'app/models/spree/taxon.rb', line 21

def applicable_filters
  fs = []
  # fs << ProductFilters.taxons_below(self)
  ## unless it's a root taxon? left open for demo purposes

  fs << ProductFilters.price_filter if ProductFilters.respond_to?(:price_filter)
  fs << ProductFilters.brand_filter if ProductFilters.respond_to?(:brand_filter)
  fs
end

Creates permalink based on Stringex’s .to_url method



32
33
34
35
36
37
38
39
# File 'app/models/spree/taxon.rb', line 32

def set_permalink
  if parent_id.nil?
    self.permalink = name.to_url if self.permalink.blank?
  else
    parent_taxon = Taxon.find(parent_id)
    self.permalink = [parent_taxon.permalink, (self.permalink.blank? ? name.to_url : self.permalink.split('/').last)].join('/')
  end
end