Skip to content

Make Product Filter Overriding Less Clunky #6406

@jarednorman

Description

@jarednorman

Currently product filters provide information on overriding them here:

    # THIS FILE SHOULD BE OVER-RIDDEN IN YOUR SITE EXTENSION!
    #   the exact code probably won't be useful, though you're welcome to modify and reuse
    #   the current contents are mainly for testing and documentation

    # To override this file...
    #   1) Make a copy of it in your sites local /lib/spree folder
    #   2) Add it to the config load path, or require it in an initializer, e.g...
    #
    #      # config/initializers/spree.rb
    #      require 'spree/product_filters'

Note: It is also unnecessarily required in a couple of tests.

However, the version that exists in core is being required in the Taxon model, here.

On a new Rails/Solidus app, you have to remove lib/spree from the autoloads (as lib is autoloaded by default now), and then make lib/spree/core/product_filters.rb file, stopping the version in core from being loaded. You need the version in core not be loaded if you want to define your own price_range_any or brand_any search scopes.

We should remove the require in the Taxon model. The Starter Frontend (which depends on the stock product filters) already explicitly requires the module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions