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, #current_spree_page?, #flash_messages, #format_price, #gem_available?, #link_to_cart, #logo, #meta_data_tags, #method_missing, #order_subtotal, #seo_url, #taxons_tree, #todays_short_date, #variant_options, #yesterdays_short_date

Instance Method Details

#active_productsObject



44
45
46
47
48
# File 'app/models/spree/taxon.rb', line 44

def active_products
  scope = 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



24
25
26
27
28
29
30
31
32
# File 'app/models/spree/taxon.rb', line 24

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



35
36
37
38
39
40
41
42
# File 'app/models/spree/taxon.rb', line 35

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