trying to display the products on the collection admin page.
in the database , the products collection saves all collections it is belongs to.
i would like to see all the products from the collection view. what would be best to achieve this?
const products: CollectionConfig = {
slug: "products",
fields: [
{
name: "collections",
type: "relationship",
relationTo: "collections",
hasMany:true
},
],
};
const collections: CollectionConfig = {
slug: 'collections',
fields: [
{
name: 'id',
type: 'text',
},
// {
// name: 'products',
// type: 'relationship',
// relationTo: 'products',
// hasMany: true
// },
],
}
Use an array of relationships:
https://payloadcms.com/docs/fields/arrayStar
Discord
online
Get dedicated engineering support directly from the Payload team.