Gestire le impostazioni omnicanale

L'API Omnichannel Settings è il punto di accesso per la configurazione dei programmi di annunci di inventario locale (LIA) e schede locali senza costi (FLL).

Utilizzalo per

  • Gestire (creare e aggiornare) le impostazioni omnicanale
  • Recupera (get e list) le impostazioni omnicanale
  • Richiedi la verifica dell'inventario per i commercianti idonei

Per saperne di più, consulta la panoramica degli annunci di inventario locale e delle schede locali senza costi.

Prerequisiti

Dovresti avere

Crea un'impostazione omnicanale

Puoi utilizzare il metodo omnichannelSettings.create per creare un'impostazione omnicanale. Il metodo create accetta una risorsa omnichannelSetting come input e restituisce l'impostazione omnicanale creata, se l'operazione va a buon fine.

Durante la creazione, devi compilare sia regionCode sia LsfType:

  • OmnichannelSetting è su base nazionale. RegionCode definisce il paese target. Una volta creato, non può essere modificato. RegionCode deve seguire la regola di denominazione definita dal progetto Common Locale Data Repository (CLDR).
  • LsfType si basa sulla tua pagina di prodotto. Per maggiori dettagli, vedi LsfType.

Per maggiori dettagli, consulta Modifica l'esperienza sulla pagina di prodotto per gli annunci di inventario locale.

Non è necessario compilare tutti i campi in fase di creazione, ma puoi configurarli in un secondo momento. Per aggiornare un omnichannelSetting esistente, consulta Aggiorna un'impostazione omnicanale.

Ecco una richiesta di esempio se scegli MHLSF_BASIC e registri inStock:

POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings

{
  "regionCode": "{REGION_CODE}",
  "lsfType: "MHLSF_BASIC",
  "inStock": {
      "uri": {URI}"
  }
}

Sostituisci quanto segue:

  • {ACCOUNT_ID}: l'identificatore univoco del tuo account Merchant Center
  • {REGION_CODE}: un codice regione definito da CLDR
  • {URI}: Un URI valido utilizzato per la recensione specificata. Un URI non idoneo potrebbe impedire l'approvazione.

Dopo che la richiesta è stata eseguita correttamente, dovresti vedere la seguente risposta:

{
  "name": "accounts/{ACCOUNT_ID}/omnichannelSettings/{omnichannel_setting}",
  "regionCode": "{REGION_CODE}",
  "lsfType: "MHLSF_BASIC",
  "inStock": {
      "uri": "{URI}",
      "state": "RUNNING"
  }
}

La registrazione di diverse funzionalità LIA/FLL utilizzando i campi omnichannelSetting attiva revisioni manuali che di solito richiedono da un paio d'ore a un paio di giorni. Ti consigliamo di controllare attentamente i dati inseriti per evitare tempi di attesa non necessari dovuti a dati non idonei.

Per visualizzare l'impostazione omnicanale appena creata o controllare lo stato delle recensioni, utilizza accounts.omnichannelSettings.get o accounts.omnichannelSettings.list, specificando il paese.

Tipo di vetrina locale (LSF)

In base alla pagina di prodotto che prevedi di utilizzare, scegli un LsfType:

Tipo di pagina di prodotto LsfType Valore enum
Pagine di prodotto con disponibilità in negozio Vetrina locale ospitata dal commerciante (implementazione di base) MHLSF_BASIC
Pagine di prodotto specifiche per i singoli negozi con disponibilità e prezzo Vetrina locale ospitata dal commerciante (implementazione completa) MHLSF_FULL
Pagine di prodotto senza disponibilità in negozio Vetrina locale ospitata da Google (GHLSF) GHLSF

Se scegli i tipi di vetrina locale ospitata dal commerciante, devi anche compilare il campo URI per almeno uno dei campi inStock o pickup.

InStock

Puoi utilizzare InStock per fornire ulteriori informazioni sulla pagina di prodotto.

Se scegli i tipi di vetrina locale ospitata dal commerciante e specifichi il campo URI in InStock, indichi l'intenzione di pubblicare prodotti con disponibilità in stock. Avvieremo una revisione in base all'URI fornito.

Se scegli il tipo GHLSF, devi fornire un campo InStock vuoto nella richiesta. A differenza dei tipi di vetrina locale ospitata dal commerciante, per completare l'onboarding devi completare la procedura di verifica dell'inventario.

Questo esempio di codice crea un omnichannelSetting con 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)

Ritiro

Oltre alla disponibilità in negozio, puoi anche migliorare i prodotti disponibili in negozio con la funzionalità di ritiro, idonea solo per i tipi di vetrina locale ospitata dal commerciante.

Quando un prodotto è contrassegnato per il ritiro, significa che un cliente può acquistarlo online e ritirarlo in negozio. Impostando il campo Pickup, indichi la tua intenzione di pubblicare prodotti con un contratto di servizio per il ritiro. Avvieremo una revisione in base all'URI fornito.

Di seguito è riportata una richiesta di esempio che crea un'impostazione omnichannel con Pickup:

POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings

{
  "regionCode": "{REGION_CODE}",
  "lsfType: "MHLSF_BASIC",
  "pickup": {
     "uri: "{URI}"
  }
}

In esposizione, può essere ordinato

Con la funzionalità In esposizione, può essere ordinato, puoi mostrare i prodotti esposti nel tuo negozio fisico, ma non disponibili per un acquisto immediato. Ad esempio, mobili di grandi dimensioni:

  • I clienti che cercano prodotti simili su Google visualizzeranno questi annunci con l'annotazione "In negozio" nei risultati di ricerca.
  • I clienti che esplorano il negozio in una pagina dei risultati di ricerca di Google vedranno questi prodotti contrassegnati come "Ordinabile".

Possono scegliere l'annuncio di inventario locale o la scheda locale senza costi per visualizzare l'articolo. Per acquistare l'articolo, possono visitare il tuo negozio fisico, visualizzarlo e quindi ordinarlo, scegliendo tra la spedizione a domicilio oppure presso il tuo negozio, dove potranno ritirarlo.

Informazioni (Germania, Austria e Svizzera)

Se pubblichi annunci in Austria e Germania e scegli GHLSF, devi inviare una pagina Informazioni.

Se pubblichi annunci in Svizzera, devi inviare una pagina "Informazioni" indipendentemente da LsfType.

Finché l'URL della pagina Informazioni non viene verificato, i commercianti GHLSF non possono richiedere la verifica dell'inventario manuale da parte di Google.

Per tutti i commercianti di questi tre paesi, il servizio non attiva le funzionalità di schede di prodotto locali senza costi/annunci di inventario locale finché la pagina Informazioni non viene approvata.

Verifica dell'inventario

La verifica dell'inventario è obbligatoria solo per i commercianti di GHLSF. Non è supportato per i tipi MHLSF.

Prima o dopo aver aggiunto i dati di prodotto e i dati di inventario (utilizzando accounts.products.localInventories.insert o l'interfaccia utente di Merchant Center), devi verificare il tuo contatto. Fornisci un contatto per la verifica dell'inventario (nome e indirizzo email) utilizzando il metodo create o update. Il contatto riceverà un'email inviata da Google e potrà verificare il proprio stato facendo clic su un pulsante nel messaggio.

Una volta completata questa operazione, puoi richiedere la verifica dell'inventario. Per saperne di più, consulta Informazioni sulla verifica dell'inventario.

Puoi modificare il contatto durante la procedura di verifica o dopo la verifica utilizzando omnichannelSetting.update.

Al termine di questa procedura, Google convalida l'accuratezza delle informazioni fornite.

Ottieni un'impostazione omnicanale

Per recuperare la configurazione di omnichannelSetting in un determinato paese o controllare lo stato attuale delle tue recensioni, utilizza il metodo omnichannelSettings.get.

Ecco una richiesta di esempio:

GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{OMNICHANNEL_SETTING}

Sostituisci quanto segue:

  • {ACCOUNT_ID}: l'identificatore univoco del tuo account Merchant Center
  • {OMNICHANNEL_SETTING}: il codice regione del paese target

Lo stato ACTIVE indica che la revisione è stata approvata.

Se lo stato è FAILED, risolvi i problemi e attiva una nuova revisione chiamando omnichannelSetting.update.

Il campo di sola lettura LFP mostra lo stato di partner per i feed locali. Per collegarti alla partnership, utilizza lfpProviders.linkLfpProvider.

Per saperne di più sul controllo degli stati e sul loro significato, consulta Visualizza lo stato di un'impostazione omnicanale.

Elenca impostazioni omnicanale

Per recuperare tutte le informazioni di omnichannelSetting per il tuo account, utilizza il metodo omnichannelSettings.list.

Ecco un esempio di codice:

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)

Aggiorna un'impostazione omnicanale

Per aggiornare la configurazione di un'impostazione omnicanale esistente, utilizza il metodo omnichannelSettings.update.

Per eseguire l'aggiornamento, devi aggiungere la funzionalità che ti interessa alla maschera di aggiornamento e compilare i campi corrispondenti nel campo omnichannelSetting della richiesta di aggiornamento. Puoi aggiornare questi elementi

  • lsfType
  • inStock
  • pickup
  • odo
  • about
  • inventoryVerification

Se un attributo non è incluso nella maschera di aggiornamento, non verrà aggiornato.

Se un attributo è incluso nella maschera di aggiornamento, ma non è impostato nella richiesta, verrà cancellato.

Il seguente esempio di codice mostra come aggiornare il campo di verifica dell'inventario.

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)

Richiedi la verifica dell'inventario

omnichannelSettings.requestInventoryVerification è pertinente solo per i commercianti di GHLSF.

Prima di chiamare questo RPC, devi aver eseguito quanto segue:

  • Carica i dati di prodotto e di inventario.
  • Verifica un contatto per la verifica dell'inventario.
  • Per i commercianti in Austria, Germania o Svizzera, completa una revisione della pagina About.

Per determinare la tua idoneità, chiama il numero omnichannelSettings.get e controlla omnichannelSetting.inventoryVerification.state. Se viene visualizzato INACTIVE, puoi chiamare 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);
  }
}

Visualizza lo stato di un'impostazione omnicanale.

Per controllare lo stato delle revisioni di onboarding degli LIA, controlla ReviewState per gli attributi corrispondenti di omnichannelSetting restituiti dai metodi omnichannelSettings.get o omnichannelSettings.list.

Il campo ReviewState si applica a tutte le revisioni di onboarding, ad eccezione della procedura di verifica dell'inventario, e può avere i seguenti valori:

  • ACTIVE: è approvato.
  • FAILED: è stato rifiutato.
  • RUNNING: è ancora in fase di revisione.
  • ACTION_REQUIRED: esiste solo nella InStock.state per i commercianti GHLSF. Significa che devi richiedere la verifica dell'inventario per pubblicare gli annunci di inventario locale.

InventoryVerification.State ha i seguenti valori:

  • SUCCEEDED: è approvato.
  • INACTIVE: puoi richiedere la verifica dell'inventario.
  • RUNNING: è in corso di revisione
  • SUSPENDED: la verifica dell'inventario non è riuscita troppe volte (di solito 5) e devi attendere prima di poterla richiedere di nuovo.
  • ACTION_REQUIRED: devi intraprendere ulteriori azioni prima di richiedere la verifica dell'inventario.

Risolvi i problemi relativi a Omnichannel Settings API

Questa sezione descrive come risolvere i problemi comuni.

Crea un'impostazione omnicanale

  • Assicurati di impostare sia LsfType che RegionCode.
  • Se scegli GHLSF, fornisci un InStock vuoto nella richiesta.
  • Se scegli i tipi di vetrina locale ospitata dal commerciante, fornisci almeno un URI in InStock o Pickup.

Aggiorna un'impostazione omnicanale

Il metodo di aggiornamento per questa risorsa richiede le seguenti regole aggiuntive:

  • Non puoi modificare il codice regione.
  • Non puoi apportare aggiornamenti mentre la funzionalità LIA/FLL è in esecuzione o è stata approvata.
  • Quando passi dai tipi di vetrina locale ospitata dal commerciante a GHLSF, se InStock e Pickup erano stati configurati in precedenza, devi includerli nella maschera di aggiornamento insieme all'aggiornamento di LsfType.

Ad esempio, se in precedenza hai applicato MHLSF_BASIC e Pickup e sono stati rifiutati, puoi passare a GHLSF inviando una richiesta come questa:

PATCH https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{REGION_CODE}?update_mask=lsf_type,in_stock,pickup

{
  "lsfType": "GHLSF",
  "inStock": {},
}

Sostituisci quanto segue:

  • {ACCOUNT_ID}: l'identificatore univoco del tuo account Merchant Center
  • {REGION_CODE}: un codice regione definito da CLDR

Richiedi la verifica dell'inventario

Se, nonostante l'aggiornamento dei feed di prodotti o di inventario e la conferma del contatto, InventoryVerification.state è diverso da INACTIVE:

  • Per i commercianti in Austria, Germania e Svizzera: assicurati di aver completato una revisione della pagina Informazioni.
  • Si verificherà un ritardo di circa 48 ore.
  • In caso di errori ripetuti del controllo dell'inventario (più di cinque), il servizio applica un periodo di attesa di 30 giorni prima di consentire un'altra richiesta. Contatta l'Assistenza Google se vuoi richiederlo prima.

Scopri di più

Per maggiori dettagli, consulta il Centro assistenza per gli annunci di inventario locale e le schede locali senza costi.