-
-
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
Store metadata for solidus resources #5951
base: main
Are you sure you want to change the base?
Store metadata for solidus resources #5951
Conversation
Aims at solving #5951 |
Sure, basically I am hoping to have Solidus support something similar to the |
What resources do you think need it most and why? |
Product, variant, order, line item, and shipment would be reasonable defaults. They are the most important core models and my experience they are the records that need additional fields in the broadest number of cases. |
Ok, given your pref for products and transactions also returns and RMA requests make sense at this point. Can you live with them + users and I stop bugging you? |
Honestly, I don't think it's super important on which models we will add those metadata fields for the core. What's more important is creating a developer-friendly journey to add more of them when needed. What I envision for the success of this initiative is:
{
"key": "serial_number",
"type": "string",
"value": "123abc",
"access": "public", // Can also be the roles which have permissions, like "admin"?
"api": true // If we want this field to be included in the REST API payloads
}
With these three elements, we have enough flexibility and we don't have to assume anything on where the fields are needed, which is without doubt something that dramatically changes from store to store. |
@kennyadsl i really feel strongly about the admin part being a @MadelineCollier task. She's deep into that right now and it would take us much more time to do that. Can we slip that into her existing work? |
Yes, but it needs to be prioritized with the rest of the tasks in that case. By the way, the feature can live without the admin part, and we can add that later, isn't it? |
For me it's an API feature with read only admin |
Given how addresses are made implications should be documented. For how it works now, would two addresses with different metadata create two different addresses or one address? @jarednorman |
Summary
This implementation extends the Solidus framework to add metadata support across multiple Spree resources. It involves database migrations, model enhancements, attribute updates, API configuration, and comprehensive testing to ensure robust functionality.
List of Resources
The following Spree resources are configured to support metadata fields:
Database Schema Updates
To support metadata, two new JSON/JSONB columns (public_metadata and private_metadata) are added to each of the above resources.
Migration
PR Model Configuration
A shared concern Spree::Metadata is introduced to handle serialization and facilitate operations on the metadata fields.
Concern Implementation
Attribute Configuration
The public_metadata and private_metadata fields are incorporated into the Spree attribute system.
Permitted Attributes
Strong Parameters
API Configuration
Testing
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: