Link products to each other with user configurable types.
Install via composer
composer require skywire/linkedproducts
Link types can be managed from the admin
Admin -> Products -> Type Management
- Code is the type identifier and will be used to retrieve products by type.
- Label can be displayed on the frontend, and is used in the admin product view form
- SKU pattern is a regex used by the auto link cron, this will find all products with a matching pattern, and link them to each other ie:
/sku-m/
notice no use of * and the addition of the slashes. - Product types are used by the auto link cron, only products of the selected types will be linked.
Admin -> Products -> Import Product Links
Provide a CSV containing these fields
- sku
- type_code
- linked_skus
"sku","type_code","linked_skus"
"24-MB01 ","Type_1","24-MB04,24-MB03,24-MB05"
"24-MB04","Type_1","24-MB01,24-MB03,24-MB05"
Note that the linked_skus are comma separated within a single field
Running the import will delete any existing links for any products found in the sku
field before creating new links
Admin -> Products -> Export Product Links
Exports all existing links, it is advised to import your links, then if you need to make a change you can export, modify and re-import.
Admin -> Stores -> Configuration -> Catalog -> Skywire Linked Products
A cron can be configured to automatically create links based on the SKU pattern, this method is advised if you are trying to link products with consistent SKU patterns eg.
- prod1-32
- prod1-33
- prod1-34
So you could use a regex to match the first part of the SKU, and the auto link will find all product SKUs starting in prod1
and link them to each other
Links can be viewed (but not edited) from the admin product edit form, under the Linked Products
tab.
A helper has been provided for this purpose.
Skywire\LinkedProducts\Helper\ProductHelper
Call getLinkedProductCollection
with the link type code and the product ID, and it will return either a product collection or false