-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing product brand using taxon_brand_selector #5989
Introducing product brand using taxon_brand_selector #5989
Conversation
Documentation has also be added here: solidusio/edgeguides#138 |
Thanks for the contribution, again. The failure seems related. Also, there's still an extra merge commit. Let me know if I can help with doing a proper rebase. |
87fb968
to
9c23ff9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5989 +/- ##
=======================================
Coverage 89.46% 89.46%
=======================================
Files 782 783 +1
Lines 17999 18011 +12
=======================================
+ Hits 16102 16113 +11
- Misses 1897 1898 +1 ☔ View full report in Codecov by Sentry. |
a7a5b0c
to
224d570
Compare
c20c992
to
2f49b21
Compare
4e2c5f9
to
df9499e
Compare
df9499e
to
c156f37
Compare
a3d6922
to
54c70ab
Compare
@kennyadsl should be fine now, sorry for not cleaning up behind ourselves :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we think this change requires a minor version bump? My main worry is that I know of existing stores that already have a brand column, and this is a breaking change for them, even if it's trivial to implement the selector in that case.
@jarednorman yes, I'd also polish the edge guide a little to contain backend instructions. |
It would be indicated. Let's see if we manage also to place meta data in that release. Deal? |
614fdf4
to
603714a
Compare
Do you mean major @jarednorman? BTW I dont' think we need to treat this change as a backward incompatibility, as it's not changing something existing. A special note in the next minor version changelog would be enough IMO. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Summary
This implementation introduces a brand concept to Spree products by adding a
brand
method to theSpree::Product
model. This method delegates brand selection to a configurable class, enabling modularity and customization.The new
Spree::TaxonBrandSelector
class fetches brands based on the Brands taxonomy. Developers can customize this functionality through thebrand_selector_class
attribute inSpree::AppConfiguration
.Implementation
Model Method Implementation
A
brand
method has been added to theSpree::Product
model to retrieve the associated brand.Changes in
Spree::Product
The new
brand
method is implemented as follows:Class Implementation
The 'Spree::TaxonBrandSelector' class encapsulates the logic for identifying the brand:
This class queries the database for taxons associated with the product and matches the 'Brands' taxonomy.
Configuration Implementation
A new configuration attribute was added to 'Spree::AppConfiguration' to specify the class responsible for selecting the brand for a product:
class_name_attribute :brand_selector_class, default: 'Spree::TaxonBrandSelector'
This configuration allows developers to override the default behavior by providing a custom class. By default, it uses 'Spree::TaxonBrandSelector'.
Testing
Unit tests were added to verify that the selector correctly identifies the first 'Brands' taxon.
RSpec Example
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: