Class: Spree::TaxonomiesController

Inherits:
StoreController show all
Defined in:
app/controllers/spree/taxonomies_controller.rb

Instance Method Summary collapse

Methods inherited from StoreController

#current_taxon, #default_products_sort, #permitted_products_params, #products_filters_params, #render_404_if_store_not_exists, #store_filter_names, #store_filter_names_hash

Methods included from AnalyticsHelper

#analytics_event_handlers, #track_event, #unsupported_event?, #visitor_id

Methods included from WishlistHelper

#current_wishlist

Methods included from PasswordProtected

#redirect_to_password

Methods included from StorefrontHelper

#as_aspect_ratio, #page_description, #page_image, #paths_equal?, #render_storefront_partials, #show_account_pane?, #spree_storefront_base_cache_key, #spree_storefront_base_cache_scope, #svg_country_icon, #tailwind_classes_for

Methods included from ThemeConcern

#default_url_options, #set_theme_view_paths

Instance Method Details

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/spree/taxonomies_controller.rb', line 3

def show
  @taxonomy = current_store.taxons.where(parent_id: nil).friendly.find(params[:id])

  @taxons = @taxonomy.children.order(name: :asc)
  taxons_grouped = @taxons.group_by { |b| b.name[0].upcase }

  numbers = ('0'..'9').to_a
  alphabet_letters = ('A'..'Z').to_a

  @taxons_grouped_by_letter = begin
    taxons_grouped_by_letter = {}
    alphabet_letters.each do |letter|
      taxons_grouped_by_letter[letter] = taxons_grouped[letter]
    end
    taxons_grouped_by_letter
  end

  @taxons_grouped_by_numbers = taxons_grouped.select { |k, _v| numbers.include?(k) }
  @taxons_grouped_by_other = taxons_grouped.select { |k, _v| alphabet_letters.concat(numbers).exclude?(k) }
end