Sha256: a3ff364f9d00dfcc9914d5e0d5a0ef79e0b50967ee7c3a718cfad472f59e4263
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module Gemgento::CategoriesHelper # Get a list of values for a given attribute. Values are based on all filters except the filter for the given # attribute. # # @param attribute [Symbol] Gemgento::Attribute code # @return [Array(String)] def filter_options(attribute) filters = @filters.select{ |f| (f[:attribute].is_a?(Array) ? f[:attribute].first[:code] : f[:attribute].code) != attribute.to_s } products = Gemgento::Product.active.catalog_visible .joins(:product_categories) .where('gemgento_product_categories.category_id = ?', @current_category.id) products = products.filter(filters) if filters.any? options = products.map(&attribute) options.uniq.reject(&:blank?).sort end # Cache key values for categories#show fragment cache. # # @return [Array] def cache_key cache_key = [@current_category] cache_key << user_signed_in? ? current_user.user_group : nil cache_key << @products.maximum(:cache_expires_at) if @products cache_key += query_params_cache_keys return cache_key end # Cache key values from query string. # # @return [Array(String)] def query_params_cache_keys [params[:page]] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gemgento-2.8.0 | app/helpers/gemgento/categories_helper.rb |