Skip to content

Commit

Permalink
Merge pull request #2782 from coorasse/feature/extend_taxons_controller
Browse files Browse the repository at this point in the history
Allow to easily extend the TaxonsController
  • Loading branch information
kennyadsl authored Jun 27, 2018
2 parents 89f7dae + a1c3530 commit 475d9db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- The promotions "Advertise" checkbox and the "URL Path" promotion activation method have been removed from the admin UI because the features are not implemented in solidus_frontend [#2737](https://github.com/solidusio/solidus/pull/2737) ([benjaminwil](https://github.com/benjaminwil)

### Frontend

- The `TaxonsController#show` action loads now the `@taxon` in a `before_action` callback. This means that if you overrode the `show` method you may be loading the `@taxon` variable twice. You can now change the behaviour of how the `@taxon` is loaded overriding the `load_taxon` method instead. [#2782](https://github.com/solidusio/solidus/pull/2782) ([coorasse](https://github.com/coorasse))

## Solidus 2.6.0 (2018-05-16)

### Major changes
Expand Down
9 changes: 6 additions & 3 deletions frontend/app/controllers/spree/taxons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ module Spree
class TaxonsController < Spree::StoreController
helper 'spree/products', 'spree/taxon_filters'

before_action :load_taxon, only: [:show]

respond_to :html

def show
@taxon = Spree::Taxon.find_by!(permalink: params[:id])
return unless @taxon

@searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true))
@products = @searcher.retrieve_products
@taxonomies = Spree::Taxonomy.includes(root: :children)
end

private

def load_taxon
@taxon = Spree::Taxon.find_by!(permalink: params[:id])
end

def accurate_title
if @taxon
@taxon.seo_title
Expand Down

0 comments on commit 475d9db

Please sign in to comment.