Overview
Associations allow you to relate products to each other. There are a few different ways you can associate two products and this type of relationship would define how they are presented on your storefront and also how Lunar sees them.Loading associations
Lunar\Models\ProductAssociation models. On each model you will have access to the following:
Types of association
Cross Sell
Cross selling is the process of encouraging customers to purchase products or services in addition to the original items they intended to purchase. Oftentimes the cross-sold items are complementary to one another so customers have more of a reason to purchase both of them. For example, if you’re selling a Phone on your store, you may want to present some headphones or a case that works with the phone which the customer may be interested in. Adding a cross-sell associationUp Sell
Upselling is the process of encouraging customers to upgrade or include add-ons to the product or service they’re buying. The product or service being promoted is typically a more expensive product or add ons which can increase the overall order value. Using the phone example from above, lets consider we have two phones.- Phone 16gb 5” Screen
 - Phone 32gb 6” Screen
 
Alternate
Alternate products are what you could present the user as an alternative to the current product. This is helpful in situations where the product might be out of stock or not quite fit for purpose and you could show these.Custom types
Although Lunar comes preloaded with the associations above, you are free to add your own custom association types.Removing associations
You can dissociate products with one simple method. If you only pass through the related models, or an array of models, all associations will be removed. If you wish to only remove associations for a certain type you can pass the type through as the second parameter.Database Schema
| Field | Description | 
|---|---|
id | |
product_id | |
product_association_id | |
type | (cross-sell, up-sell, alternate) | 
created_at | |
updated_at |