logo
logo

Extend content collections for products

By default, users can only add Sitecore Content Marketing Platform (CMP)™ content items to content collections. However, as a superuser, you can extend the content collections to work with other entity definitions.

In this configuration example, we extend content collections to add Sitecore Product Content Management (PCM)™ products. We want to be able to:

Add existing products

To allow adding new products to content collections, we need to:

  1. Create a relation between content collections and products.
  2. Edit the search component of the Content collection details page.
  3. Edit the creation component of the Content collection details page.

Create a relation

To create a relation between content collections and products:

  1. On the menu bar, click Manage , and then click Schema.

  2. On the Schema page, find the M.ContentCollections entity definition, and click it.

  3. On the M.ContentCollections page, to add a new member group, click New group.

  4. In the New member group dialog box, enter a Name (here we use Product):

  5. In the Product group, to add a new member, click New member.

  6. In the New member dialog box, in RELATION, click Select.

  7. Fill in the following fields:

    • Name: ContentCollectionsToPCM, for example
    • Associated definition: M.PCM.Product
    • Cardinality: ManyToMany

  8. Click Save.

  9. Back on the M.ContentCollections page, click Apply changes.

Edit the search component

To find the Content search component:

  1. On the menu bar, click Manage .

  2. Click Pages and find the Content collection details page.

  3. On the Content search component, to enable custom settings, click .

Now, to allow the Content search component to find M.PCM.Product entities, we need to:

  1. Edit the filters to include M.PCM.Product.
  2. Edit the output to include the desired product fields in the grid view.
  3. Make the same changes to the Add existing items component.

Filters

To edit the Content search component's filters:

  1. On the menu bar, click Manage .

  2. Click Pages and find the Content collection details page.

  3. On the Content search component, to enable custom settings, click .

  4. To edit the Content search component, click it.

  5. In Filters, on the System tab, click Edit and change the combine operator from and to or:

  6. To confirm the change, click Save.

  7. Click Add filter , select the Product (M.PCM.Product) definition in the drop-down list, and click Save:

  8. To change fixed filter settings, click the Fixed tab and click Edit .

  9. Change the field values as follows:

    • Input type: Page entity
    • Filter type: Ancestor
    • Name: ContentCollection*

      Note

      The * symbol is a wildcard. It filters content collection dynamic data. In this case, it filters the ContentCollectionsToPCM and ContentCollectionToContent members.

  10. Change the Filter type back to Relation and click Save.

Output

To edit the Content search component's output:

  1. On the Content search component page, click the Output tab.
  2. To edit the products' grid view, click Grid and click the M.PCM.Product block.
  3. To add the desired fields, scroll down to Fields and click Add : here we include the Name field:

  4. Click Save.

Note

The grid view is the default view to display content with thumbnails.

Edit the Add existing items component

Now, make changes to the Add existing items component's filters and output as follows:

  1. On the Content collection details page, on the Add existing items component, to enable custom settings, click .

  2. To edit the Add existing items component, click it.

  3. In Filters, on the System tab, click Edit and change the combine operator from and to or.

  4. To confirm your change, click Save.

  5. Click the Output tab.

  6. To edit the products' grid view, click Grid and click the M.PCM.Product block.

  7. To add the desired fields, scroll down to Fields and click Add : here we include the Name field.

  8. To confirm your changes, click Save.

Edit the creation component

To allow the Creation component to link existing products to content collections:

  1. On the Content collection details page, on the Creation component, to enable custom settings, click .

  2. To edit the Creation component, click it.

  3. Click Link items, and then click Add definition.

  4. In the drop-down list, select the ContentCollectionsToPCM relation:

  5. To confirm your changes, click Save.

  6. Click the General section.

  7. Add a label, either a Default or Custom option.

  8. In Linked search component, select Content search and Add existing items:

  9. To confirm your changes, click Save and close.

Configuration test

To test, view the details page of a Content collection as follows:

  1. On the menu bar, click Content and select Content collections.

  2. Click the desired content collection to open it.

  3. Click Add and click + Add existing items:

    • In the Add existing items dialog box, you can now select products.

      Tip

      Configuring search facets as shown on the example above allows better searchibility.

Add new products

To allow adding new products to content collections:

  1. On the menu bar, click Manage .

  2. Click Pages and find the Content collection details page.

  3. On the Creation component, to enable custom settings, click .

  4. To edit the Creation component, click it.

  5. Clicks New entities, and then click Add definition.

  6. In the drop-down list, select M.PCM.Product.

  7. Fill in the fields as follows:

    • Label type: Default or Custom. Here, we select Default.
    • Detail Page: here, we select Product creation (the template page for the creation of a new product).
    • Window type: defines the size of the dialog box for the product creation (Medium modal is the default):

  8. Under DEFAULT VALUES, click Add value.

  9. In the drop-down lists, select ContentCollectionsToPCM* and Current entity.

  10. To confirm your changes, at the bottom-right of the screen, click Save.

  11. To save all changes to the component, on the top-right of the screen click Save or Save and close.

Configuration test

To test, view the details page of a Content collection as follows:

  1. On the menu bar, click Content and select Content collections.

  2. Click the desired content collection to open it.

  3. Click Add:

    • You can see that there is a + Product option to add a new product:

  4. Click + Product.

  5. In the Product dialog box, enter the required values and click Save.

  6. In the Product modal, enter the values required for the new product, and click Save:

    • Our new product appears in the content collection:

    Tip

    To remove, edit or delete products from a content collection, edit the Selection component to define operations for M.PCM.Product.

Can we improve this article ? Provide feedback