Class: Spree::Taxon

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

Instance Method Summary collapse

Methods included from ProductFilters

all_taxons, brand_filter, format_price, price_filter, selective_brand_filter, taxons_below

Instance Method Details

#active_productsObject



48
49
50
51
52
# File 'app/models/spree/taxon.rb', line 48

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



28
29
30
31
32
33
34
35
36
# File 'app/models/spree/taxon.rb', line 28

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



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

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