Sha256: a5fb1df9ef91f2fb24592ff90152f6108f17d3bad388764d40aed01795bbf7b7

Contents?: true

Size: 723 Bytes

Versions: 10

Compression:

Stored size: 723 Bytes

Contents

module TaxonsHelper
  # Retrieves the collection of products to display when "previewing" a taxon.  This is abstracted into a helper so
  # that we can use configurations as well as make it easier for end users to override this determination.  One idea is
  # to show the most popular products for a particular taxon (that is an exercise left to the developer.)
  def taxon_preview(taxon, max=4)
    products = taxon.active_products.limit(max)
    if (products.size < max) && Spree::Config[:show_descendents]
      taxon.descendants.each do |taxon|
        to_get = max - products.length
        products += taxon.active_products.limit(to_get)
        break if products.size >= max
      end
    end
    products
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_core-0.70.7 app/helpers/taxons_helper.rb
spree_core-0.70.6 app/helpers/taxons_helper.rb
spree_core-0.70.5 app/helpers/taxons_helper.rb
spree_core-0.70.4 app/helpers/taxons_helper.rb
spree_core-0.70.3 app/helpers/taxons_helper.rb
spree_core-0.70.2 app/helpers/taxons_helper.rb
spree_core-0.70.1 app/helpers/taxons_helper.rb
spree_core-0.70.0 app/helpers/taxons_helper.rb
spree_core-0.70.0.rc2 app/helpers/taxons_helper.rb
spree_core-0.70.RC1 app/helpers/taxons_helper.rb