# Sovrn (Viglink) module

### Getting API Key and Secret Key

To find your API key and Secret key for a site:

1. Log into the Sovrn Platform.
2. Go to Commerce > Settings > Site.
3. Under Actions, click on the Key to view the API keys for that site.
4. If no secret key has been created, click on "Generate Secret Key".

<figure><img src="https://4254262503-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3fnB7iKYwDc1Xhr3H3%2Fuploads%2Ft12n3n0WLOkikS0KV9D0%2Fimage.png?alt=media&#x26;token=296eeadc-c7af-45d1-b27b-0c8a27e69901" alt=""><figcaption></figcaption></figure>

### Price comparison

The module allows you to search for a specific product in the Sovrn database and obtain all offers for that product. You simply need to provide a product URL from any supported retailer.

<figure><img src="https://4254262503-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3fnB7iKYwDc1Xhr3H3%2Fuploads%2Fq15zzIcwfEH4X0hifZJI%2Fimage.png?alt=media&#x26;token=36481cff-0a36-415c-abcc-77bbf545cb99" alt=""><figcaption></figcaption></figure>

### Price filter

Sovrn API provides a simple search function that returns all products with keywords in the product title. To find the desired product, it is recommended to add a filter by price.

<figure><img src="https://4254262503-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3fnB7iKYwDc1Xhr3H3%2Fuploads%2Fw1BKD3103rE6l3bcuEZp%2Fimage.png?alt=media&#x26;token=36c035d5-7f3f-4ca9-a24e-41fadd7778cd" alt=""><figcaption></figcaption></figure>

### Merchnat domains

Unfortunately, the Sovrn API does not return direct product URLs or merchant domains. As a result, some merchant domains may not be detected correctly. To resolve this, add the following code to your `functions.php` file with merchant-to-domain pairs like this:

```php
function my_viglink_merchant2domain($m2d)
{
    $m2d['Verizon'] = 'verizon.com';
    $m2d['Lowe\'s'] = 'lowes.com';
    $m2d['Dell'] = 'dell.com';

    return $m2d;
}

add_filter('cegg_viglink_merchant2domain', 'my_viglink_merchant2domain');
```
