-
-
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
Add brand from config #5952
Add brand from config #5952
Conversation
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 for the contribution @shahmayur001!
Please, squash all commits into a single one with a meaningful title and description. Please, read all our contributing guidelines, in particular here.
It would also be great to:
- update our seeds/samples to include a brand on the products, now that we have this, to make it more real.
- document what a brand is on the guides, including how to customize the brand class with your own logic.
@kennyadsl There's no content about products or taxonomies what so every in the documentation. Where do you want the section for brands to be added? |
@shahmayur001 Here you can find the sample data: |
…onics/solidus into add_brand_from_config
We released two new gems and need the appropriate labels for the pull request reviews.
This commit allows the menu of the new admin to accomodate routes from other engines than solidus backend and solidus admin. This is needed for `solidus_promotions`, which is built as a separate Rails Engine, but it is also convenient for `solidus_paypal_commerce_platform` or even for integrating gems like AlchemyCMS lateron. Co-Authored-By: [email protected]
This makes sure that the promotion menus are always below the product menu item, in both new admin and the backend. It also changes the nomenclature to be "Promotions" for the legacy promotion system and "Promotions (new)" for the new promotion system.
Prior to this commit, the new promotion system would exchange the promotion and promotion category index page components if the gem was loaded. This made it impossible to actually see the old promotion configuration when using the new admin. This commit now only changes the orders/index component if the new promotion system is activated. In any case, it will display new promotion and promotion category records under "Promotions (new)".
Not sure how we missed that when including `solidus_promotions`.
The `authorization_subject` method from `solidus_admin` assumes that all models are in the `Spree` namespace.
This controller still did not know how what to authorize against, and wanted to visit a URL that doesn't exist when clicking on a promotion. This also changes at least the name of each promotion to be a link element that can easily be targeted with Capybara and works with all major browsers.
Previously this would force the development server to run on 3000, but it is useful to be able to override that. Co-authored-by: Harmony Evangelina <[email protected]>
…onics/solidus into add_brand_from_config
This reverts commit 4191737.
Creates a solidus sample brand and adds all products
…onics/solidus into add_brand_from_config
@jarednorman We are also integrating the taxons for brands inside the starter-frontend, at that point it makes sense to remove solidus from the product name in the sample data. Is that ok for you? |
…onics/solidus into add_brand_from_config
Closing this PR as a clean version has been created: #5989. |
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: