Spree::AppConfiguration object includes getters and setters for Solidus
classes as extension points.
Before extending any class, study the standard implementation of it carefully. Once you understand the implementation, you can use Solidus's provided extension points to subclass or re-implement it for your store.
Solidus's service class extension points can be found as part of the
object, where each line that
class_name_attribute defines a different extension point.
When you extend a class, you can change the behavior of a single feature or your entire store.
For example, you can change what appears in a customer's search results by
. This way, you do not
need to completely rewrite Solidus's searcher. Solidus provides a class
extension point for this:
class_name_attribute :searcher_class, default: 'Spree::Core::Search::Base'
Note that if you do not use this extension point, then
defaults to using
Extending the searcher is a multi-step process:
get_base_scopemethod to override in classes that inherit from
:searcher_classextension point in the Solidus initializer at
MyStore::ProductSearch class, rewrite the
get_base_scope method with our desired
module MyStore class ProductSearch < Spree::Core::Search::Base private def get_base_scope super.where("name LIKE '%Ruby%'") end end end
This searcher only displays search results that pass on to the
variable and have the string
Ruby in their name.
Then, you can apply your searcher to the extension point in your
require 'my_store/product_search' Spree.config do |config| config.searcher_class = MyStore::ProductSearch end
Now, when the search is built it uses your extended
functionality instead of the default functionality.
If you see yourself overriding a class with a definable interface, and there is no associated extension point, consider submitting a pull request for your changeable class.
Solidus is an open source platform supported by the community. We encourage everyone using Solidus to contribute back to the documentation and the code.