Allow product association types to be customised#2357
Merged
glennjacobs merged 10 commits into1.xfrom Dec 8, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a customizable enum-based system for product association types to replace hard-coded string constants, improving type safety and extensibility.
Key Changes:
- Deprecated the use of string constants (
UP_SELL,CROSS_SELL,ALTERNATE) on theProductAssociationmodel - Introduced a new
ProductAssociationenum with aProvidesProductAssociationTypeinterface - Added configuration support to allow developers to replace the default enum with custom implementations
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/core/Unit/Models/ProductTest.php | Updated test cases to use the new enum instead of string constants |
| packages/core/src/Models/ProductAssociation.php | Added deprecation notices to constants and refactored scopes to use enum values |
| packages/core/src/Models/Product.php | Updated method signatures to type-hint ProvidesProductAssociationType instead of string |
| packages/core/src/Models/Contracts/ProductAssociation.php | Updated interface to accept enum type in scopeType method |
| packages/core/src/Models/Contracts/Product.php | Updated interface method signatures to use enum type-hint |
| packages/core/src/LunarServiceProvider.php | Added 'products' to the configuration files list |
| packages/core/src/Jobs/Products/Associations/Associate.php | Updated to use enum type and access enum value property |
| packages/core/src/Base/Enums/ProductAssociation.php | New enum implementing ProvidesProductAssociationType with label method |
| packages/core/src/Base/Enums/Concerns/ProvidesProductAssociationType.php | New interface defining the contract for product association type enums |
| packages/core/config/products.php | New configuration file for customizing the association types enum |
| packages/admin/src/Filament/Resources/ProductResource/Pages/ManageProductAssociations.php | Updated to use getTypes() method and enum-based formatting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
@alecritson generally looks good, but I think we need to consider translations. |
Collaborator
Author
Added some translations |
wychoong
reviewed
Nov 28, 2025
glennjacobs
approved these changes
Dec 8, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR to allow product association types to be customised.
UP_SELLon the modelCloses #2337