L'API Omnichannel Settings est le point d'entrée pour configurer vos programmes d'annonces produits en magasin et de fiches locales gratuites.
Utilisez-la pour effectuer les opérations suivantes de manière automatisée :
- Gérer (créer et mettre à jour) les paramètres omnicanaux
- Récupérer (obtenir et lister) les paramètres omnicanaux
- Demander la vérification de l'inventaire pour les marchands éligibles
Pour en savoir plus, consultez la présentation des annonces produits en magasin et des fiches locales gratuites.
Prérequis
Vous devez disposer des éléments suivants :
Un compte Merchant Center
Une fiche d'établissement (si vous n'en avez pas, vous pouvez en créer une). Consultez Créer une fiche d'établissement.
Un lien entre votre fiche d'établissement et votre compte Merchant Center (pour créer le lien, vous pouvez utiliser l'interface utilisateur Merchant Center ou l'API Merchant. Consultez Associer une fiche d'établissement Google).
Créer un paramètre omnicanal
Vous pouvez utiliser la méthode omnichannelSettings.create pour créer un paramètre omnicanal. La méthode de création prend une ressource omnichannelSetting comme entrée et renvoie le paramètre omnicanal créé, si l'opération réussit.
Lors de la création, vous devez renseigner à la fois regionCode et le
LsfType :
- Le paramètre omnicanal est défini par pays.
RegionCodedéfinit le pays cible. Une fois créé, vous ne pouvez plus le modifier.RegionCodedoit suivre la règle de nommage définie par le Common Locale Data Repository (CLDR) projet. LsfTypeest basé sur votre page produit. Pour en savoir plus, consultezLsfType.
Pour en savoir plus, consultez Modifier l'expérience sur la page produit pour vos annonces produits en magasin.
Vous n'avez pas besoin de remplir tous les champs lors de la création, mais vous pouvez les configurer ultérieurement. Pour mettre à jour un omnichannelSetting existant, consultez
Mettre à jour un paramètre omnicanal.
Voici un exemple de requête si vous choisissez MHLSF_BASIC et que vous vous inscrivez à inStock :
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": {URI}"
}
}
Remplacez les éléments suivants :
{ACCOUNT_ID}: identifiant unique de votre compte Merchant Center{REGION_CODE}: code de région tel que défini par CLDR{URI}: URI valide utilisé pour l'examen donné. Un URI non éligible peut empêcher l'approbation.
Une fois la requête exécutée, la réponse suivante s'affiche :
{
"name": "accounts/{ACCOUNT_ID}/omnichannelSettings/{omnichannel_setting}",
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"inStock": {
"uri": "{URI}",
"state": "RUNNING"
}
}
L'inscription à différentes fonctionnalités d'annonces produits en magasin/de fiches locales gratuites à l'aide des champs omnichannelSetting déclenche des examens manuels qui prennent généralement entre quelques heures et quelques jours. Nous vous recommandons de vérifier vos entrées pour éviter un délai d'attente inutile en raison de données non éligibles.
Pour afficher le paramètre omnicanal que vous venez de créer ou vérifier l'état des examens, utilisez accounts.omnichannelSettings.get ou accounts.omnichannelSettings.list, en spécifiant le pays.
Type de page vitrine du magasin (LSF)
En fonction de la page produit que vous prévoyez d'utiliser, choisissez un LsfType :
| Type de page produit | LsfType | Valeur d'énumération |
|---|---|---|
| Pages produit avec disponibilité en magasin | Page vitrine du magasin hébergée par le marchand (version de base) | MHLSF_BASIC |
| Pages produit spécifiques à un magasin avec disponibilité et prix | Page vitrine du magasin hébergée par le marchand (version complète) | MHLSF_FULL |
| Pages produit sans disponibilité en magasin | Page vitrine du magasin hébergée par Google (GHLSF) | GHLSF |
Si vous choisissez des types de pages vitrines du magasin hébergées par le marchand, vous devez également renseigner
le champ URI pour au moins l'un des éléments suivants : inStock ou pickup.
InStock
Vous pouvez utiliser InStock pour fournir plus d'informations sur votre page produit.
Si vous choisissez des types de pages vitrines du magasin hébergées par le marchand et que vous spécifiez le champ URI dans InStock, vous indiquez que vous souhaitez diffuser des produits avec disponibilité en stock. Nous lancerons un examen en fonction de l'URI fourni.
Si vous choisissez le type GHLSF, vous devez fournir un champ InStock vide dans la requête. Contrairement aux types de pages vitrines du magasin hébergées par le marchand, pour finaliser le processus d'intégration, vous devez
effectuer le processus de vérification de l'inventaire.
Cet exemple de code crée un omnichannelSetting avec GHLSF :
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.CreateOmnichannelSettingRequest;
import com.google.shopping.merchant.accounts.v1.InStock;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting.LsfType;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to create an omnichannel setting for a given Merchant Center account
* in a given country
*/
public class CreateOmnichannelSettingSample {
public static void createOmnichannelSetting(Config config, String regionCode) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String parent = AccountName.newBuilder().setAccount(accountId).build().toString();
// Creates an omnichannel setting with GHLSF type in the given country.
CreateOmnichannelSettingRequest request =
CreateOmnichannelSettingRequest.newBuilder()
.setParent(parent)
.setOmnichannelSetting(
OmnichannelSetting.newBuilder()
.setRegionCode(regionCode)
.setLsfType(LsfType.GHLSF)
.setInStock(InStock.getDefaultInstance())
.build())
.build();
System.out.println("Sending create omnichannel setting request:");
OmnichannelSetting response =
omnichannelSettingsServiceClient.createOmnichannelSetting(request);
System.out.println("Inserted Omnichannel Setting below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
createOmnichannelSetting(config, regionCode);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\CreateOmnichannelSettingRequest;
use Google\Shopping\Merchant\Accounts\V1\InStock;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting\LsfType;
/**
* This class demonstrates how to create an omnichannel setting for a given
* Merchant Center account in a given country.
*/
class CreateOmnichannelSetting
{
/**
* Helper to create the parent string.
*
* @param string $accountId The merchant account ID.
* @return string The parent string in the format `accounts/{account}`.
*/
private static function getParent(string $accountId): string
{
return sprintf('accounts/%s', $accountId);
}
/**
* Creates an omnichannel setting for a given Merchant Center account.
*
* @param array $config The configuration file for authentication.
* @param string $regionCode The country for the omnichannel setting.
*/
public static function createOmnichannelSettingSample(
array $config,
string $regionCode
): void {
// Obtains OAuth credentials from the configuration file.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates a client.
$omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
'credentials' => $credentials
]);
// Constructs the parent resource name.
$parent = self::getParent($config['accountId']);
// Creates the omnichannel setting with GHLSF type in the given country.
$omnichannelSetting = new OmnichannelSetting([
'region_code' => $regionCode,
'lsf_type' => LsfType::GHLSF,
'in_stock' => new InStock()
]);
// Creates the request.
$request = new CreateOmnichannelSettingRequest([
'parent' => $parent,
'omnichannel_setting' => $omnichannelSetting
]);
// Calls the API and prints the response.
try {
printf("Sending create omnichannel setting request:%s", PHP_EOL);
$response = $omnichannelSettingsServiceClient->createOmnichannelSetting($request);
printf("Inserted Omnichannel Setting below:%s", PHP_EOL);
print $response->serializeToJsonString(true) . PHP_EOL;
} catch (ApiException $e) {
printf("An error has occured: %s", $e->getMessage());
}
}
/**
* Executes the sample.
*/
public function callSample(): void
{
$config = Config::generateConfig();
// The country which you're targeting.
$regionCode = '{REGION_CODE}';
self::createOmnichannelSettingSample($config, $regionCode);
}
}
// Runs the script.
$sample = new CreateOmnichannelSetting();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import CreateOmnichannelSettingRequest
from google.shopping.merchant_accounts_v1 import InStock
from google.shopping.merchant_accounts_v1 import OmnichannelSetting
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
def create_omnichannel_setting(account_id: str, region_code: str) -> None:
"""Creates an omnichannel setting for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
region_code: The country for which you're creating the setting.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The parent account under which to create the setting.
parent = f"accounts/{account_id}"
# Creates an omnichannel setting with GHLSF type in the given country.
omnichannel_setting = OmnichannelSetting()
omnichannel_setting.region_code = region_code
omnichannel_setting.lsf_type = OmnichannelSetting.LsfType.GHLSF
omnichannel_setting.in_stock = InStock()
# Creates the request.
request = CreateOmnichannelSettingRequest(
parent=parent, omnichannel_setting=omnichannel_setting
)
# Makes the request and catches and prints any error messages.
try:
print("Sending create omnichannel setting request:")
response = client.create_omnichannel_setting(request=request)
print("Inserted Omnichannel Setting below:")
print(response)
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
# The country which you're targeting.
_REGION_CODE = "{REGION_CODE}"
create_omnichannel_setting(_ACCOUNT, _REGION_CODE)
Retrait
Outre la disponibilité en magasin, vous pouvez également améliorer vos produits en magasin grâce à la fonctionnalité de retrait, qui n'est éligible que pour les types de pages vitrines du magasin hébergées par le marchand.
Lorsqu'un produit est marqué pour le retrait, cela signifie qu'un client peut l'acheter en ligne et le retirer en magasin. En définissant le champ Pickup, vous indiquez que vous souhaitez diffuser des produits avec une disponibilité pour retrait. Nous lancerons un examen en fonction de l'URI fourni.
Voici un exemple de requête qui crée un paramètre omnichannel avec Pickup :
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"pickup": {
"uri: "{URI}"
}
}
Exposé et disponible sur commande
Avec la fonctionnalité Exposé et disponible sur commande, vous pouvez présenter des produits qui sont exposés dans votre magasin physique, mais qui ne peuvent pas être achetés immédiatement. Par exemple, les meubles volumineux :
- Les clients en quête de produits similaires sur Google verront apparaître ces annonces avec l'annotation "en magasin" dans leurs résultats de recherche.
- Les clients qui parcourent le magasin sur une page de résultats de recherche Google verront ces produits marqués comme "disponibles sur commande".
Ils peuvent choisir votre annonce produits en magasin ou votre fiche locale gratuite pour afficher l'article. Pour acheter l'article, ils peuvent se rendre dans votre magasin physique, voir l'article, puis le commander pour qu'il leur soit expédié ou qu'il soit expédié à votre magasin pour retrait.
À propos (Allemagne, Autriche et Suisse)
Si vous diffusez des annonces en Autriche et en Allemagne et que vous choisissez GHLSF, vous devez envoyer une
page "À propos".
Si vous diffusez des annonces en Suisse, vous devez envoyer une page "À propos", quel que soit le LsfType.
Tant que l'URL de la page "À propos" n'est pas validée, les marchands GHLSF ne peuvent pas demander de validation manuelle de l'inventaire à Google.
Pour tous les marchands de ces trois pays, le service n'active pas les fonctionnalités de fiches locales gratuites/APM tant que votre page "À propos" n'est pas approuvée.
Validation de l'inventaire
La validation de l'inventaire n'est requise que pour les marchands GHLSF. Elle n'est pas compatible avec les types MHLSF.
Avant ou après avoir ajouté des données produit et des données d'inventaire (à l'aide de accounts.products.localInventories.insert ou de l'interface utilisateur Merchant Center), vous devez valider votre contact. Fournissez un contact pour la vérification de l'inventaire (nom et adresse e-mail) à l'aide de la méthode create ou update. Le contact recevra un e-mail envoyé par Google et pourra valider son état en cliquant sur un bouton dans le message.
Une fois cette opération terminée, vous pouvez demander la validation de l'inventaire. Pour en savoir plus, consultez À propos de la vérification de l'inventaire.
Vous pouvez modifier votre contact pendant le processus de validation ou après la validation à l'aide de omnichannelSetting.update.
Une fois ce processus terminé, Google valide l'exactitude des informations fournies.
Obtenir un paramètre omnicanal
Pour récupérer la configuration omnichannelSetting dans un pays donné ou vérifier
l'état actuel de vos examens, utilisez la méthode omnichannelSettings.get.
Voici un exemple de requête :
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{OMNICHANNEL_SETTING}
Remplacez les éléments suivants :
{ACCOUNT_ID}: identifiant unique de votre compte Merchant Center{OMNICHANNEL_SETTING}: code de région de votre pays cible
L'état ACTIVE indique que l'examen a été approuvé.
Si l'état est FAILED, résolvez les problèmes et déclenchez un nouvel examen en appelant omnichannelSetting.update.
Le champ LFP en lecture seule indique l'état de votre partenariat avec les flux locaux. Pour créer un lien vers le partenariat, utilisez lfpProviders.linkLfpProvider.
Pour en savoir plus sur la vérification des états et leur signification, consultez Afficher l' état d'un paramètre omnicanal.
Lister les paramètres omnicanaux
Pour récupérer toutes les informations omnichannelSetting de votre compte, utilisez la
omnichannelSettings.list méthode.
Voici un exemple de code :
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.ListOmnichannelSettingsRequest;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient.ListOmnichannelSettingsPagedResponse;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to get the list of omnichannel settings for a given Merchant Center
* account
*/
public class ListOmnichannelSettingsSample {
public static void omnichannelSettings(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String accountId = config.getAccountId().toString();
String parent = AccountName.newBuilder().setAccount(accountId).build().toString();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
ListOmnichannelSettingsRequest request =
ListOmnichannelSettingsRequest.newBuilder().setParent(parent).build();
System.out.println("Sending list omnichannel setting request:");
ListOmnichannelSettingsPagedResponse response =
omnichannelSettingsServiceClient.listOmnichannelSettings(request);
int count = 0;
// Iterates over all the entries in the response.
for (OmnichannelSetting omnichannelSetting : response.iterateAll()) {
System.out.println(omnichannelSetting);
count++;
}
System.out.println(String.format("The following count of elements were returned: %d", count));
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
omnichannelSettings(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\ListOmnichannelSettingsRequest;
/**
* This class demonstrates how to get the list of omnichannel settings for a
* given Merchant Center account.
*/
class ListOmnichannelSettings
{
/**
* Helper to create the parent string.
*
* @param string $accountId The merchant account ID.
* @return string The parent string in the format `accounts/{account}`.
*/
private static function getParent(string $accountId): string
{
return sprintf('accounts/%s', $accountId);
}
/**
* Lists the omnichannel settings for a given Merchant Center account.
*
* @param array $config The configuration file for authentication.
*/
public static function listOmnichannelSettingsSample(array $config): void
{
// Obtains OAuth credentials from the configuration file.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates a client.
$omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
'credentials' => $credentials
]);
// Constructs the parent resource name.
$parent = self::getParent($config['accountId']);
// Creates the request.
$request = new ListOmnichannelSettingsRequest(['parent' => $parent]);
// Calls the API and prints the response.
try {
printf("Sending list omnichannel setting request:%s", PHP_EOL);
$response = $omnichannelSettingsServiceClient->listOmnichannelSettings($request);
$count = 0;
// Iterates over all the omnichannel settings and prints them.
foreach ($response->iterateAllElements() as $omnichannelSetting) {
print $omnichannelSetting->serializeToJsonString(true) . PHP_EOL;
$count++;
}
printf("The following count of elements were returned: %d%s", $count, PHP_EOL);
} catch (ApiException $e) {
printf("An error has occured: %s", $e->getMessage());
}
}
/**
* Executes the sample.
*/
public function callSample(): void
{
$config = Config::generateConfig();
self::listOmnichannelSettingsSample($config);
}
}
// Runs the script.
$sample = new ListOmnichannelSettings();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import ListOmnichannelSettingsRequest
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
def list_omnichannel_settings(account_id: str) -> None:
"""Lists the omnichannel settings for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The parent account for which to list the settings.
parent = f"accounts/{account_id}"
# Creates the request.
request = ListOmnichannelSettingsRequest(parent=parent)
# Makes the request and catches and prints any error messages.
try:
print("Sending list omnichannel setting request:")
response = client.list_omnichannel_settings(request=request)
count = 0
# Iterates over all the entries in the response.
for omnichannel_setting in response:
print(omnichannel_setting)
count += 1
print(f"The following count of elements were returned: {count}")
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
list_omnichannel_settings(_ACCOUNT)
Mettre à jour un paramètre omnicanal
Pour mettre à jour la configuration d'un paramètre omnicanal existant, utilisez la méthode omnichannelSettings.update.
Pour effectuer une mise à jour, vous devez ajouter la fonctionnalité souhaitée au masque de mise à jour et renseigner les champs correspondants dans le champ omnichannelSetting de la requête de mise à jour.
Vous pouvez mettre à jour n'importe quel élément parmi les suivants :
lsfTypeinStockpickupodoaboutinventoryVerification
Si un attribut n'est pas inclus dans le masque de mise à jour, il ne sera pas mis à jour.
Si un attribut est inclus dans le masque de mise à jour, mais qu'il n'est pas défini dans la requête, il sera effacé.
L'exemple de code suivant montre comment mettre à jour le champ de vérification de l'inventaire.
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.protobuf.FieldMask;
import com.google.shopping.merchant.accounts.v1.InventoryVerification;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.UpdateOmnichannelSettingRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to update an omnichannel setting for a given Merchant Center account
* in a given country
*/
public class UpdateOmnichannelSettingSample {
public static void updateOmnichannelSettings(
Config config, String regionCode, String contact, String email) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String name =
OmnichannelSettingName.newBuilder()
.setAccount(accountId)
.setOmnichannelSetting(regionCode)
.build()
.toString();
OmnichannelSetting omnichannelSetting =
OmnichannelSetting.newBuilder()
.setName(name)
.setInventoryVerification(
InventoryVerification.newBuilder()
.setContact(contact)
.setContactEmail(email)
.build())
.build();
FieldMask fieldMask = FieldMask.newBuilder().addPaths("inventory_verification").build();
UpdateOmnichannelSettingRequest request =
UpdateOmnichannelSettingRequest.newBuilder()
.setOmnichannelSetting(omnichannelSetting)
.setUpdateMask(fieldMask)
.build();
System.out.println("Sending update omnichannel setting request:");
OmnichannelSetting response =
omnichannelSettingsServiceClient.updateOmnichannelSetting(request);
System.out.println("Updated Omnichannel Setting below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
// The name of the inventory verification contact you want to update.
String contact = "{NAME}";
// The address of the inventory verification email you want to update.
String email = "{EMAIL}";
updateOmnichannelSettings(config, regionCode, contact, email);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\InventoryVerification;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting;
use Google\Shopping\Merchant\Accounts\V1\UpdateOmnichannelSettingRequest;
/**
* This class demonstrates how to update an omnichannel setting for a given
* Merchant Center account in a given country.
*/
class UpdateOmnichannelSetting
{
/**
* Helper to create the name string.
*
* @param string $accountId The merchant account ID.
* @param string $regionCode The region code of the setting.
* @return string The name string in the format
* `accounts/{account}/omnichannelSettings/{omnichannelSetting}`.
*/
private static function getName(string $accountId, string $regionCode): string
{
return sprintf('accounts/%s/omnichannelSettings/%s', $accountId, $regionCode);
}
/**
* Updates an omnichannel setting for a given Merchant Center account.
*
* @param array $config The configuration file for authentication.
* @param string $regionCode The country of the omnichannel setting.
* @param string $contact The name of the inventory verification contact.
* @param string $email The email of the inventory verification contact.
*/
public static function updateOmnichannelSettingSample(
array $config,
string $regionCode,
string $contact,
string $email
): void {
// Obtains OAuth credentials from the configuration file.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates a client.
$omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
'credentials' => $credentials
]);
// Constructs the resource name.
$name = self::getName($config['accountId'], $regionCode);
// Creates the omnichannel setting with the updated fields.
$omnichannelSetting = new OmnichannelSetting([
'name' => $name,
'inventory_verification' => new InventoryVerification([
'contact' => $contact,
'contact_email' => $email
])
]);
// Creates the field mask to specify which fields to update.
$fieldMask = new FieldMask([
'paths' => ['inventory_verification']
]);
// Creates the request.
$request = new UpdateOmnichannelSettingRequest([
'omnichannel_setting' => $omnichannelSetting,
'update_mask' => $fieldMask
]);
// Calls the API and prints the response.
try {
printf("Sending update omnichannel setting request:%s", PHP_EOL);
$response = $omnichannelSettingsServiceClient->updateOmnichannelSetting($request);
printf("Updated Omnichannel Setting below:%s", PHP_EOL);
print $response->serializeToJsonString(true) . PHP_EOL;
} catch (ApiException $e) {
printf("An error has occured: %s", $e->getMessage());
}
}
/**
* Executes the sample.
*/
public function callSample(): void
{
$config = Config::generateConfig();
// The country which you're targeting.
$regionCode = '{REGION_CODE}';
// The name of the inventory verification contact you want to update.
$contact = '{NAME}';
// The address of the inventory verification email you want to update.
$email = '{EMAIL}';
self::updateOmnichannelSettingSample($config, $regionCode, $contact, $email);
}
}
// Runs the script.
$sample = new UpdateOmnichannelSetting();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.protobuf import field_mask_pb2
from google.shopping.merchant_accounts_v1 import InventoryVerification
from google.shopping.merchant_accounts_v1 import OmnichannelSetting
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
from google.shopping.merchant_accounts_v1 import (
UpdateOmnichannelSettingRequest,
)
def update_omnichannel_setting(
account_id: str, region_code: str, contact: str, email: str
) -> None:
"""Updates an omnichannel setting for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
region_code: The country for which you're updating the setting.
contact: The name of the inventory verification contact.
email: The email of the inventory verification contact.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The name of the omnichannel setting to update.
name = f"accounts/{account_id}/omnichannelSettings/{region_code}"
# Creates an omnichannel setting with the updated values.
omnichannel_setting = OmnichannelSetting()
omnichannel_setting.name = name
omnichannel_setting.inventory_verification = InventoryVerification(
contact=contact, contact_email=email
)
# Creates a field mask to specify which fields to update.
field_mask = field_mask_pb2.FieldMask(paths=["inventory_verification"])
# Creates the request.
request = UpdateOmnichannelSettingRequest(
omnichannel_setting=omnichannel_setting, update_mask=field_mask
)
# Makes the request and catches and prints any error messages.
try:
print("Sending update omnichannel setting request:")
response = client.update_omnichannel_setting(request=request)
print("Updated Omnichannel Setting below:")
print(response)
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
# The country which you're targeting.
_REGION_CODE = "{REGION_CODE}"
# The name of the inventory verification contact you want to update.
_CONTACT = "{NAME}"
# The address of the inventory verification email you want to update.
_EMAIL = "{EMAIL}"
update_omnichannel_setting(_ACCOUNT, _REGION_CODE, _CONTACT, _EMAIL)
Demander la vérification de l'inventaire
omnichannelSettings.requestInventoryVerification ne concerne que les marchands GHLSF.
Avant d'appeler ce RPC, vous devez avoir effectué les opérations suivantes :
- Importer vos données produit et d'inventaire
- Valider un contact pour la vérification de l'inventaire
- Pour les marchands d'Autriche, d'Allemagne ou de Suisse, effectuer un examen de la
Aboutpage
Pour déterminer votre éligibilité, appelez omnichannelSettings.get et vérifiez omnichannelSetting.inventoryVerification.state. Si la valeur est INACTIVE, vous pouvez appeler omnichannelSettings.requestInventoryVerification.
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.RequestInventoryVerificationRequest;
import com.google.shopping.merchant.accounts.v1.RequestInventoryVerificationResponse;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to request inventory verification for a given Merchant Center account
* in a given country
*/
public class RequestInventoryVerificationSample {
public static void requestInventoryVerification(Config config, String regionCode)
throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String name =
OmnichannelSettingName.newBuilder()
.setAccount(accountId)
.setOmnichannelSetting(regionCode)
.build()
.toString();
RequestInventoryVerificationRequest request =
RequestInventoryVerificationRequest.newBuilder().setName(name).build();
System.out.println("Sending request inventory verification request:");
RequestInventoryVerificationResponse response =
omnichannelSettingsServiceClient.requestInventoryVerification(request);
System.out.println("Omnichannel Setting after inventory verification request below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
requestInventoryVerification(config, regionCode);
}
}
Afficher l'état d'un paramètre omnicanal
Pour vérifier l'état d'examen des examens d'intégration des annonces produits en magasin, consultez ReviewState
pour les attributs correspondants de omnichannelSetting renvoyés par les
omnichannelSettings.get ou omnichannelSettings.list méthodes.
Le champ ReviewState s'applique à tous les examens d'intégration, à l'exception du processus de vérification de l'inventaire, et peut présenter les valeurs suivantes :
ACTIVE: approuvéFAILED: refuséRUNNING: toujours en cours d'examenACTION_REQUIRED: n'existe que dansInStock.statepour les marchands GHLSF. Cela signifie que vous devez demander la vérification de l'inventaire pour que les APM soient diffusées.
InventoryVerification.State présente les valeurs suivantes :
SUCCEEDED: approuvéINACTIVE: vous pouvez demander la vérification de l'inventaireRUNNING: en cours d'examenSUSPENDED: vous avez échoué trop de fois à la vérification de l'inventaire (généralement cinq fois) et vous devez attendre avant de pouvoir la demander à nouveauACTION_REQUIRED: vous devez effectuer des actions supplémentaires avant de demander la vérification de l'inventaire
Résoudre les problèmes liés à Omnichannel Settings API
Cette section explique comment résoudre les problèmes courants.
Créer un paramètre omnicanal
- Veillez à définir
LsfTypeetRegionCode. - Si vous choisissez
GHLSF, fournissez unInStockvide dans la requête. - Si vous choisissez des types de pages vitrines du magasin hébergées par le marchand, fournissez au moins un URI dans
InStockouPickup.
Mettre à jour un paramètre omnicanal
La méthode de mise à jour de cette ressource nécessite les règles supplémentaires suivantes :
- Vous ne pouvez pas modifier le code de région.
- Vous ne pouvez pas effectuer de mises à jour lorsque la fonctionnalité APM/fiches locales gratuites est en cours d'exécution ou a été approuvée.
- Lorsque vous passez de types de pages vitrines du magasin hébergées par le marchand à
GHLSF, siInStocketPickupont été configurés précédemment, vous devez les inclure dans le masque de mise à jour avec la mise à jourLsfType.
Par exemple, si vous avez appliqué MHLSF_BASIC et Pickup auparavant et qu'ils ont été refusés, vous pouvez passer à GHLSF en envoyant une requête comme celle-ci :
PATCH https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{REGION_CODE}?update_mask=lsf_type,in_stock,pickup
{
"lsfType": "GHLSF",
"inStock": {},
}
Remplacez les éléments suivants :
{ACCOUNT_ID}: identifiant unique de votre compte Merchant Center{REGION_CODE}: code de région tel que défini par CLDR
Demander la vérification de l'inventaire
Si, malgré la mise à jour des flux de produits ou d'inventaire et la confirmation du contact, InventoryVerification.state est différent de INACTIVE :
- Pour les marchands d'Autriche, d'Allemagne et de Suisse : assurez-vous d'avoir effectué un examen de la page "À propos".
- Il y aura un délai d'environ 48 heures.
- En cas d'échecs répétés de la vérification de l'inventaire (plus de cinq), le service applique une période de refroidissement de 30 jours avant d'autoriser une autre demande. Contactez l'assistance Google si vous souhaitez la demander plus tôt.
En savoir plus
Pour en savoir plus, consultez le Centre d'aide Annonces produits en magasin et fiches locales gratuites.