---
title: "Using the ModelReference field renderer in rendering variants"
slug: "using-the-modelreference-field-renderer-in-rendering-variants"
abstract: "The ModelReference field renderer provides you with the ability to use rendering variants to reference models with nested objects (such as product bundles)."
---
# Using the ModelReference field renderer in rendering variants

SXA comes with a set of default renderings and [rendering variants](https://doc.sitecore.com/xp/en/developers/sxa/101/sitecore-experience-accelerator/create-a-rendering-variant.html) (including the `Reference` and the `Model` field renderers). To process a model property of the type collection, however, you must use the `ModelReference` field renderer.

The `ModelReference` field renderer iterates over a specified collection in the rendering model and allows you to extract data using additional Model field renderers as subitems. You specify the collection in the **Pass through field** field of the item. The model collection property that it targets must implement the `IEnumerable` interface.

![Rendering variant structure diagram.](https://doc.sitecore.com/api/markdown-image/xp/en/developers/101/sitecore-experience-commerce/images/ModelReference.png)

You can use any standard field renderer in a nested fashion below the `ModelReference` field renderer. You can also nest the `ModelReference` field renderer to target collection properties in models with multiple levels of nested objects (hierarchies) as shown in the following illustration for the Product Bundle - Deprecated.

![ModelReferenceContentTree94.png](https://doc.sitecore.com/api/markdown-image/xp/en/developers/101/sitecore-experience-commerce/images/ModelReferenceContentTree94.png)

The following class diagram shows an example of how you can use the `ModelReference` field renderer. In the diagram, there are four nested collections through which the `ModelReference` renderer is used to iterate over the default rendering variant of the product bundle component:

- The `ProductBundleRenderingModel` iterates through the `LineItems` collection.
- The `ProductVariant` class iterates through the `VariantSelections` collection.
- The `BundleVariantsReference` iterates through the `ValidProductVariants` collection.
- The `Options` class iterates through the `Options` collection.
- The `BundleValueVariantsReference` iterates through the `Variants` collection.

![Diagram of the Product Bundle Rendering Model](https://doc.sitecore.com/api/markdown-image/xp/en/developers/101/sitecore-experience-commerce/images/ProductBundleModel.png)

You can [customize the product bundle](https://doc.sitecore.com/xp/en/developers/101/sitecore-experience-commerce/customizing-the-product-bundle-rendering.html "Customizing the Product Bundle rendering") by modifying the Scriban template.

To use the `ModelReference` renderer, you must create a rendering model class with a collection property. The model class must inherit from the `VariantsRenderingModel`.

```csharp
using Sitecore.XA.Foundation.Variants.Abstractions.Models;
namespace ProductList.Models
{
    public class ProductListRenderingModel: VariantsRenderingModel
    {
        public ICollection<Product> Products { get; set; }
    }
}

```

<details>
<summary><h2>Configuration</h2></summary>

To register the `ModelReference` field renderer in the `Sitecore.Commerce.XA.Foundation.Common.config` configuration file, use the following code snippet:

```xml
<sitecore>
    <services>
        <register                             serviceType="Sitecore.Commerce.XA.Foundation.Common.RenderingVariants.Services.ICollectionPropertyExtractor, Sitecore.Commerce.XA.Foundation.Common" implementationType="Sitecore.Commerce.XA.Foundation.Common.RenderingVariants.Services.CollectionPropertyExtractor, Sitecore.Commerce.XA.Foundation.Common" lifetime="Singleton"/>
    </services>

<parseVariantFields>
    <processor type="Sitecore.Commerce.XA.Foundation.Common.RenderingVariants.ParseVariantFields.ParseModelReference, Sitecore.Commerce.XA.Foundation.Common" resolve="true" />
</parseVariantFields>

<renderVariantField>
    <processor type="Sitecore.Commerce.XA.Foundation.Common.Pipelines.RenderVariantField.RenderModelReference, Sitecore.Commerce.XA.Foundation.Common" resolve="true" />
</renderVariantField>
</sitecore>

```

</details>