---
title: Push SAP products to Coveo by country
slug: p2ba0081
canonical_url: https://docs.coveo.com/en/p2ba0081/
collection: coveo-for-commerce
source_format: adoc
---
# Push SAP products to Coveo by country

When pushing data from SAP Commerce Cloud (version 2105 or later) to a [Coveo organization](https://docs.coveo.com/en/185.md), you can automatically push products to various Coveo [sources](https://docs.coveo.com/en/246.md) based on their availability in different countries.

> **Note**
>
> To use this feature, you must use a specific version of the Coveo extension:
>
> *  Version `3.3.1` or later for v3.
>
> *  Version `2.1.5` or later for v2.

To ensure that products and [variants](https://docs.coveo.com/en/mc7f0326.md) are only available in the correct source, populate the `SnField` called `coveoAuthorizedCountries` for each product with the correct values.

When pushing data to Coveo, use [value providers](https://docs.coveo.com/en/ladf2011.md#step-10-use-the-value-providers) to set field values.
There are two ways to populate the `coveoAuthorizedCountries` field:

* [Out-of-the-box value provider](#out-of-the-box-value-provider)

* [Custom value provider](#custom-value-provider)

## Out-of-the-box value provider

Use the existing `productAttributeSnIndexerValueProvider` provider if all of your products have an `Authorized Countries` attribute that specifies where they're available.

The [Coveo SAP Commerce indexer push extension](https://docs.coveo.com/en/ladf2011.md) automatically populates the `coveoAuthorizedCountries` field with the value of the `Authorized Countries` attribute.

For a given product:

* If the `Authorized Countries` attribute is empty, the product is sent to all sources.
* If the attribute is set, the product is restricted to sources that match the listed countries.

## Custom value provider

Create a custom value provider to populate the `coveoAuthorizedCountries` field based on the product's availability in different countries.

The following code snippet shows how to create a custom value provider:

```java
package com.coveo.indexer.service.impl;

import de.hybris.platform.core.model.c2l.CountryModel;
import de.hybris.platform.core.model.product.ProductModel;
import de.hybris.platform.searchservices.indexer.SnIndexerException;
import de.hybris.platform.searchservices.indexer.service.SnIndexerContext;
import de.hybris.platform.searchservices.indexer.service.SnIndexerFieldWrapper;
import de.hybris.platform.searchservices.indexer.service.impl.AbstractSnIndexerValueProvider;

import java.util.Collection;
import java.util.Set;

public class CustomAuthCountryValueProvider extends AbstractSnIndexerValueProvider<ProductModel, Void> {

    protected static final Set<Class<?>> SUPPORTED_QUALIFIER_CLASSES = Set.of();

    @Override
    protected Object getFieldValue(SnIndexerContext indexerContext, SnIndexerFieldWrapper fieldWrapper, ProductModel source, Void data) throws SnIndexerException {
        Collection<CountryModel> countries = getCountries(source); // <1>
        return countries; // <2>
    }

    private Collection<CountryModel> getCountries(ProductModel source) {
        return source.getCoveoAuthorizedCountries();
    }

    @Override
    public Set<Class<?>> getSupportedQualifierClasses() throws SnIndexerException {
        return SUPPORTED_QUALIFIER_CLASSES;
    }
}
```
<1> Use custom logic to get the countries where the product is available.
<2> Return the countries as a `Collection<CountryModel>` object.