-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Primary Taxon feature to Spree products
- Introduced a new `primary_taxon_id` reference field in the `spree_products` table to associate a primary breadcrumb taxon with products. - Updated the `Spree::Product` model to include a `belongs_to :primary_taxon` association, allowing optional linkage to a taxon. - Modified the `Spree::Api::ApiConfiguration` to include `primary_taxon_id` in `product_attributes`, enabling API support for this attribute. - Enhanced API tests to cover creation and updating of products with a primary taxon. - Updated the admin product form to allow selection of a primary taxon. - Improved frontend JavaScript for autocomplete functionality when selecting a primary taxon. - Added `primary_taxon_id` to the list of permitted attributes for safe updates via the admin interface and API. - Included test cases to verify the functionality of the `primary_taxon` association, ensuring proper model validation and API behavior. This change is backward-compatible, allowing products to exist without a primary breadcrumb taxon while enhancing the product management capabilities in both the admin interface and API.
- Loading branch information
1 parent
efe8b97
commit f7f91c0
Showing
10 changed files
with
111 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
core/db/migrate/20250207104016_add_primary_taxon_to_products.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddPrimaryTaxonToProducts < ActiveRecord::Migration[7.0] | ||
def change | ||
change_table :spree_products do |t| | ||
t.references :primary_taxon, { to_table: :spree_taxons } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters