Skip to content

Conversation

@alecritson
Copy link
Collaborator

PR to allow product association types to be customised.

  • Deprecates the use of constants like UP_SELL on the model
  • Introduces a new enum to handle association types
  • Allow the enum to be replaced in config by developers.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the ProductAssociation model
  • Introduced a new ProductAssociation enum with a ProvidesProductAssociationType interface
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants