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-le pour effectuer les opérations suivantes par programmation :
- 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 Présentation des annonces produits en magasin et des fiches locales gratuites.
Prérequis
Vous devez avoir
un compte Merchant Center ;
une fiche d'établissement. Si vous n'en avez pas, vous pouvez en créer un. Consultez Créer une fiche d'établissement.
Il s'agit d'un lien entre votre fiche d'établissement et votre compte Merchant Center. Pour créer ce lien, vous pouvez utiliser l'interface utilisateur Merchant Center ou l'API Merchant (voir 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 "create" prend une ressource omnichannelSetting en entrée et renvoie le paramètre omnicanal créé, si l'opération réussit.
Lorsque vous créez un événement, vous devez remplir les champs regionCode et LsfType :
- OmnichannelSetting est défini par pays.
RegionCodedéfinit le pays ciblé. Une fois créé, vous ne pouvez plus le modifier.RegionCodedoit respecter la règle de dénomination définie par le projet Common Locale Data Repository (CLDR). LsfTypeest basé sur votre page produit. Pour plus d'informations, consultez la sectionLsfType.
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'avis donné. Une 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'activation de différentes fonctionnalités LIA/FLL à 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 saisies pour éviter un temps 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 avis, utilisez accounts.omnichannelSettings.get ou accounts.omnichannelSettings.list en spécifiant le pays.
Type de page vitrine du magasin
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 propres à un magasin avec la disponibilité et le prix | Vitrine du magasin hébergée par le marchand (version complète) | MHLSF_FULL |
| Pages produit sans disponibilité en magasin | Vitrine du magasin hébergée par Google | GHLSF |
Si vous choisissez des types de vitrine de magasin hébergée par le marchand, vous devez également renseigner le champ URI pour au moins l'un des types inStock ou pickup.
InStock
Vous pouvez utiliser InStock pour fournir plus d'informations sur votre page produit.
Si vous choisissez des types de vitrine locale hébergée par le marchand et que vous spécifiez le champ URI dans InStock, vous indiquez votre intention de diffuser des produits disponibles en stock. Nous allons commencer l'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 FSF hébergés par le marchand, vous devez suivre la procédure de vérification de l'inventaire pour finaliser l'intégration.
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
En plus de la disponibilité en magasin, vous pouvez également améliorer vos produits en magasin grâce à la fonctionnalité de retrait, qui n'est disponible que pour les types de Fiche d'établissement hébergée par le marchand.
Lorsqu'un produit est marqué comme disponible pour retrait, cela signifie qu'un client peut l'acheter en ligne et le retirer en magasin. En définissant le champ Pickup, vous indiquez votre intention de proposer des produits avec une disponibilité pour retrait. Nous lancerons un examen en fonction de l'URI fournie.
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
La fonctionnalité Exposé et disponible sur commande vous permet de présenter des produits qui sont exposés dans votre magasin physique, mais qui ne peuvent pas être achetés immédiatement. Par exemple, pour les meubles imposants :
- 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 à la commande".
Ils peuvent cliquer sur votre annonce produit en magasin ou votre fiche locale gratuite pour consulter l'article. Pour l'acheter, ils peuvent se rendre dans votre magasin physique, voir l'article, puis le commander pour qu'il soit livré chez eux ou dans votre magasin.
À propos (Allemagne, Autriche et Suisse)
Si vous diffusez des annonces en Allemagne ou en Autriche 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 LsfType.
Tant que l'URL de la page "À propos" n'est pas validée, les marchands GHLSF ne peuvent pas demander de vérification manuelle de l'inventaire à Google.
Pour tous les marchands de ces trois pays, le service n'active pas les fonctionnalités FLL/LIA tant que votre page "À propos" n'a pas été approuvée.
Vérification de l'inventaire
La vérification 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 d'inventaire (à l'aide de accounts.products.localInventories.insert ou de l'interface utilisateur Merchant Center), vous devez valider votre contact. Indiquez un contact (nom et adresse e-mail) pour la vérification de l'inventaire à l'aide de la méthode create ou update. Le contact recevra un e-mail envoyé par Google et pourra valider son statut en cliquant sur un bouton dans le message.
Une fois cette étape terminée, vous pouvez demander la vérification 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 avis, 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 du pays ciblé
L'état ACTIVE indique que l'avis a été approuvé.
Si l'état est FAILED, corrigez 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 pour les flux en magasin. Pour créer un lien vers le partenariat, utilisez lfpProviders.linkLfpProvider.
Pour savoir comment vérifier les états et ce qu'ils signifient, 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 méthode omnichannelSettings.list.
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)
Modifier 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 modifier les informations suivantes :
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 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 :
- Importez vos données produit et d'inventaire.
- Validez un contact chargé de la vérification de l'inventaire.
- Si vous êtes marchand en Allemagne, en Autriche ou en Suisse, faites examiner votre page
About.
Pour déterminer votre éligibilité, appelez omnichannelSettings.get et vérifiez omnichannelSetting.inventoryVerification.state. Si INACTIVE s'affiche, 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);
}
}
Affichez l'état d'un paramètre omnicanal.
Pour vérifier l'état des examens d'intégration des annonces produits en magasin, consultez ReviewState pour les attributs correspondants de omnichannelSetting renvoyés par les méthodes omnichannelSettings.get ou omnichannelSettings.list.
Le champ ReviewState s'applique à tous les examens d'intégration, à l'exception du processus de vérification de l'inventaire. Il peut avoir les valeurs suivantes :
ACTIVE: elle est approuvée.FAILED: elle est refusée.RUNNING: il est toujours en cours d'examen.ACTION_REQUIRED: n'existe que dansInStock.statepour les marchands GHLSF. Cela signifie que vous devez demander la vérification de l'inventaire pour que les annonces en magasin soient diffusées.
InventoryVerification.State peut avoir les valeurs suivantes :
SUCCEEDED: elle est approuvée.INACTIVE: Vous êtes prêt à demander la vérification de l'inventaire.RUNNING: en cours d'examenSUSPENDED: vous avez échoué à la vérification de l'inventaire à de trop nombreuses reprises (généralement cinq). Vous devez patienter avant de pouvoir la demander à nouveau.ACTION_REQUIRED: Vous devez prendre des mesures 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 demande. - Si vous choisissez des types de Fiche de stock locale hébergée par le marchand, fournissez au moins un URI dans
InStockouPickup.
Modifier un paramètre omnicanal
La méthode d'actualisation de cette ressource nécessite les règles supplémentaires suivantes :
- Vous ne pouvez pas modifier le code régional.
- Vous ne pouvez pas effectuer de modifications lorsque la fonctionnalité LIA/FLL est en cours d'exécution ou a été approuvée.
- Lorsque vous passez des types de FLS hébergés par le marchand à
GHLSF, siInStocketPickupétaient configurés précédemment, vous devez les inclure dans le masque de mise à jour avec la mise à jourLsfType.
Par exemple, si vous avez déjà demandé à utiliser MHLSF_BASIC et Pickup, mais que votre demande a été refusée, 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 en Allemagne, en Autriche et en Suisse : assurez-vous d'avoir effectué l'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 impose une période d'attente de 30 jours avant d'autoriser une nouvelle demande. Contactez l'assistance Google si vous souhaitez le recevoir plus tôt.
En savoir plus
Pour en savoir plus, consultez le Centre d'aide Annonces produits en magasin et fiches locales gratuites.