ओमनीचैनल की सेटिंग मैनेज करना

Omnichannel Settings API, स्थानीय इन्वेंट्री विज्ञापनों (एलआईए) और मुफ़्त में दिखाई जाने वाली स्थानीय लिस्टिंग (एफ़्एलएल) प्रोग्राम को कॉन्फ़िगर करने का एंट्री पॉइंट है.

इसका इस्तेमाल, प्रोग्राम के ज़रिए इन कामों के लिए करें:

  • Omnichannel Settings को मैनेज करना (बनाना और अपडेट करना)
  • Omnichannel Settings को फ़ेच करना (पाना और उनकी सूची देखना)
  • ज़रूरी शर्तें पूरी करने वाले व्यापारियों के लिए, इन्वेंट्री की पुष्टि का अनुरोध करना

ज़्यादा जानकारी के लिए, स्थानीय इन्वेंट्री विज्ञापनों और मुफ़्त में दिखाई जाने वाली स्थानीय लिस्टिंग की खास जानकारी देखें.

ज़रूरी शर्तें

आपके पास ये होने चाहिए:

  • Merchant Center खाता

  • Business Profile. अगर आपके पास Business Profile नहीं है, तो उसे बनाया जा सकता है. Business Profile के लिए साइन अप करना लेख देखें.

  • Business Profile और Merchant Center खाते के बीच लिंक. लिंक बनाने के लिए, Merchant Center के यूज़र इंटरफ़ेस (यूआई) या Merchant API का इस्तेमाल किया जा सकता है. इसके लिए, Google Business Profile को लिंक करना लेख देखें.

Omnichannel सेटिंग बनाना

omnichannelSettings.create तरीके का इस्तेमाल करके, omnichannel सेटिंग बनाई जा सकती है. create तरीके में, omnichannelSetting संसाधन को इनपुट के तौर पर लिया जाता है. साथ ही, अगर यह तरीका काम करता है, तो बनाई गई omnichannel सेटिंग को आउटपुट के तौर पर दिखाया जाता है.

सेटिंग बनाते समय, आपको regionCode और LsfType, दोनों फ़ील्ड भरने होंगे:

  • OmnichannelSetting, हर देश के हिसाब से अलग होती है. RegionCode से, टारगेट किए गए देश की जानकारी मिलती है. सेटिंग बनाने के बाद, इसे बदला नहीं जा सकता. RegionCode के लिए, Common Locale Data Repository (सीएलडीआर) प्रोजेक्ट के तय किए गए नामकरण के नियम का पालन करना चाहिए.
  • LsfType, आपके प्रॉडक्ट पेज पर आधारित होता है. ज़्यादा जानकारी के लिए, LsfType देखें.

ज़्यादा जानकारी के लिए, अपने स्थानीय इन्वेंट्री विज्ञापनों के लिए, प्रॉडक्ट पेज के अनुभव में बदलाव करना लेख देखें.

सेटिंग बनाते समय, सभी फ़ील्ड भरने की ज़रूरत नहीं है. इन्हें बाद में भी कॉन्फ़िगर किया जा सकता है. किसी मौजूदा omnichannelSetting को अपडेट करने के लिए, omnichannel सेटिंग अपडेट करना लेख देखें.

अगर आपको MHLSF_BASIC चुनना है और inStock को रजिस्टर करना है, तो अनुरोध का सैंपल यहां दिया गया है:

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

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

इनकी जगह ये डालें:

  • {ACCOUNT_ID}: आपके Merchant Center खाते का यूनीक आइडेंटिफ़ायर
  • {REGION_CODE}: सीएलडीआर के मुताबिक तय किया गया रीजन कोड
  • {URI}: दी गई समीक्षा के लिए इस्तेमाल किया गया मान्य यूआरआई. अमान्य यूआरआई की वजह से, समीक्षा को मंज़ूरी नहीं मिल सकती.

अनुरोध के सफलतापूर्वक प्रोसेस होने के बाद, आपको यह जवाब दिखेगा:

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

omnichannelSetting फ़ील्ड का इस्तेमाल करके, एलआईए/एफ़्एलएल की अलग-अलग सुविधाओं को रजिस्टर करने पर, मैन्युअल समीक्षाएं ट्रिगर होती हैं. इनमें आम तौर पर, कुछ घंटे से लेकर कुछ दिन तक लग सकते हैं. हमारा सुझाव है कि आप अपने इनपुट की दोबारा जांच करें, ताकि अमान्य डेटा की वजह से, आपको बिना वजह इंतज़ार न करना पड़े.

नई बनाई गई omnichannel सेटिंग देखने या समीक्षाओं की स्थिति की जांच करने के लिए, देश की जानकारी देकर accounts.omnichannelSettings.get या accounts.omnichannelSettings.list का इस्तेमाल करें.

लोकल स्टोरफ़्रंट (एलएसएफ़) का टाइप

जिस प्रॉडक्ट पेज का इस्तेमाल करना है उसके आधार पर, कोई LsfType चुनें:

प्रॉडक्ट पेज का टाइप LsfType Enum वैल्यू
स्टोर में प्रॉडक्ट की उपलब्धता बताने वाले पेज व्यापारी का होस्ट किया गया लोकल स्टोरफ़्रंट (बेसिक) MHLSF_BASIC
स्टोर में मौजूद खास प्रॉडक्ट के पेज जिन पर प्रॉडक्ट की खरीदारी के लिए उपलब्धता और उसकी कीमत दिखाई गई है व्यापारी का होस्ट किया गया लोकल स्टोरफ़्रंट (फ़ुल) MHLSF_FULL
प्रॉडक्ट के ऐसे पेज जिन पर स्टोर में खरीदारी के लिए उपलब्धता की जानकारी नहीं है Google का होस्ट किया गया लोकल स्टोरफ़्रंट (जीएचएलएसएफ़) GHLSF

अगर व्यापारी के होस्ट किए गए लोकल स्टोरफ़्रंट के टाइप चुने जाते हैं, तो आपको कम से कम एक inStock या pickup के लिए, यूआरआई फ़ील्ड भी भरना होगा.

InStock

InStock का इस्तेमाल करके, प्रॉडक्ट पेज के बारे में ज़्यादा जानकारी दी जा सकती है.

अगर व्यापारी के होस्ट किए गए एलएसएफ़ के टाइप चुने जाते हैं और InStock में यूआरआई फ़ील्ड की जानकारी दी जाती है, तो इसका मतलब है कि आप ऐसे प्रॉडक्ट दिखाना चाहते हैं जो स्टॉक में उपलब्ध हैं. हम दिए गए यूआरआई के आधार पर समीक्षा शुरू करेंगे.

अगर GHLSF टाइप चुना जाता है, तो आपको अनुरोध में, InStock फ़ील्ड को खाली छोड़ना होगा. व्यापारी के होस्ट किए गए एलएसएफ़ के टाइप के उलट, ऑनबोर्डिंग की प्रोसेस पूरी करने के लिए, आपको इन्वेंट्री की पुष्टि की प्रोसेस पूरी करनी होगी.

कोड के इस सैंपल से, GHLSF के साथ omnichannelSetting बनता है:

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)

Pickup

स्टोर में प्रॉडक्ट की उपलब्धता के अलावा, स्टोर में मौजूद प्रॉडक्ट को बेहतर बनाने के लिए, पिकअप की सुविधा भी जोड़ी जा सकती है. यह सुविधा सिर्फ़ व्यापारी के होस्ट किए गए एलएसएफ़ के टाइप के लिए उपलब्ध है.

जब किसी प्रॉडक्ट को पिकअप के लिए मार्क किया जाता है, तो इसका मतलब है कि ग्राहक उसे ऑनलाइन खरीद सकता है और स्टोर से पिक अप कर सकता है. Pickup फ़ील्ड सेट करके, यह दिखाया जाता है कि आप ऐसे प्रॉडक्ट दिखाना चाहते हैं जिनके लिए पिकअप एसएलए उपलब्ध है. हम दिए गए यूआरआई के आधार पर समीक्षा शुरू करेंगे.

यहां अनुरोध का एक सैंपल दिया गया है. इससे Pickup के साथ omnichannel सेटिंग बनती है:

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

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

ऑर्डर करने के लिए डिसप्ले

ऑर्डर करने के लिए डिसप्ले सुविधा का इस्तेमाल करके, ऐसे प्रॉडक्ट दिखाए जा सकते हैं जो आपकी दुकान में डिसप्ले किए जाते हैं, लेकिन तुरंत खरीदने के लिए उपलब्ध नहीं होते. उदाहरण के लिए, बड़े फ़र्निचर:

  • ये विज्ञापन, Google पर मिलते-जुलते प्रॉडक्ट खोजने वाले खरीदारों को खोज के नतीजों में "स्टोर में जाकर" एनोटेशन के साथ दिखेंगे.
  • ये प्रॉडक्ट, Google पर खोज के नतीजों वाले पेज में स्टोर ब्राउज़ करने वाले खरीदारों को "ऑर्डर करने के लिए उपलब्ध" लेबल से साथ दिखेंगे.

खरीदार, आइटम देखने के लिए आपके स्थानीय इन्वेंट्री विज्ञापन या मुफ़्त में दिखाई जाने वाली स्थानीय लिस्टिंग में से कोई एक चुन सकते हैं. आइटम खरीदने के लिए, वे आपकी दुकान पर जाकर उसे देख सकते हैं. इसके बाद, वे आइटम को अपने पते पर शिप करवाने या स्टोर से पिक अप करने के लिए ऑर्डर कर सकते हैं.

इसके बारे में जानकारी (जर्मनी, ऑस्ट्रिया, और स्विट्ज़रलैंड)

अगर ऑस्ट्रिया और जर्मनी में सेवाएं दी जा रही हैं और GHLSF चुना जाता है, तो आपको इसके बारे में जानकारी वाला पेज सबमिट करना होगा.

अगर स्विट्ज़रलैंड में सेवाएं दी जा रही हैं, तो LsfType के बावजूद, आपको "इसके बारे में जानकारी" वाला पेज सबमिट करना होगा.

जब तक 'इसके बारे में जानकारी' वाले पेज के यूआरएल की पुष्टि नहीं हो जाती, तब तक GHLSF के व्यापारी, Google से इन्वेंट्री की मैन्युअल पुष्टि का अनुरोध नहीं कर सकते.

इन तीनों देशों में मौजूद सभी व्यापारियों के लिए, 'इसके बारे में जानकारी' वाले पेज को मंज़ूरी मिलने तक, सेवा में एफ़्एलएल/एलआईए की सुविधाएं चालू नहीं होती हैं.

इन्वेंट्री की पुष्टि

इन्वेंट्री की पुष्टि सिर्फ़ GHLSF के व्यापारियों के लिए ज़रूरी है. यह MHLSF टाइप के लिए उपलब्ध नहीं है.

प्रॉडक्ट डेटा और इन्वेंट्री डेटा जोड़ने से पहले या बाद में, आपको अपने संपर्क की पुष्टि करनी होगी. इसके लिए, accounts.products.localInventories.insert या Merchant Center के यूज़र इंटरफ़ेस (यूआई) का इस्तेमाल किया जा सकता है. create या update तरीके का इस्तेमाल करके, इन्वेंट्री की पुष्टि करने वाले व्यक्ति (नाम और ईमेल पता) की जानकारी दें. संपर्क करने वाले व्यक्ति को Google की ओर से एक ईमेल मिलेगा. साथ ही, मैसेज में मौजूद बटन पर क्लिक करके, वह अपने स्टेटस की पुष्टि कर पाएगा.

यह प्रोसेस पूरी होने के बाद, इन्वेंट्री की पुष्टि का अनुरोध किया जा सकता है. ज़्यादा जानकारी के लिए, इन्वेंट्री की पुष्टि करने के बारे में जानकारी देखें.

पुष्टि की प्रोसेस के दौरान या पुष्टि के बाद, omnichannelSetting.update का इस्तेमाल करके, संपर्क करने वाले व्यक्ति की जानकारी बदली जा सकती है.

यह प्रोसेस पूरी होने के बाद, Google दी गई जानकारी की पुष्टि करता है.

Omnichannel सेटिंग पाना

किसी देश में omnichannelSetting के कॉन्फ़िगरेशन को वापस पाने या अपनी समीक्षाओं का मौजूदा स्टेटस देखने के लिए, omnichannelSettings.get तरीके का इस्तेमाल करें.

अनुरोध का एक सैंपल यहां दिया गया है:

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

इनकी जगह ये डालें:

  • {ACCOUNT_ID}: आपके Merchant Center खाते का यूनीक आइडेंटिफ़ायर
  • {OMNICHANNEL_SETTING}: टारगेट किए गए देश का रीजन कोड

ACTIVE स्टेटस से पता चलता है कि समीक्षा को मंज़ूरी मिल गई है.

अगर स्टेटस FAILED है, तो समस्याओं को ठीक करें और omnichannelSetting.update को कॉल करके, नई समीक्षा ट्रिगर करें.

सिर्फ़ पढ़ने के लिए उपलब्ध LFP फ़ील्ड, लोकल फ़ीड पार्टनरशिप का स्टेटस दिखाता है. पार्टनरशिप से लिंक करने के लिए, lfpProviders.linkLfpProvider का इस्तेमाल करें.

स्टेटस और उनके मतलब की जांच करने के बारे में ज़्यादा जानकारी के लिए, omnichannel सेटिंग का स्टेटस देखना लेख देखें.

Omnichannel Settings की सूची देखना

अपने खाते के लिए omnichannelSetting की सभी जानकारी वापस पाने के लिए, omnichannelSettings.list तरीके का इस्तेमाल करें.

यहां कोड का एक सैंपल दिया गया है:

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)

Omnichannel सेटिंग अपडेट करना

किसी मौजूदा omnichannel सेटिंग के कॉन्फ़िगरेशन को अपडेट करने के लिए, omnichannelSettings.update तरीके का इस्तेमाल करें.

अपडेट करने के लिए, आपको अपडेट मास्क में वह सुविधा जोड़नी होगी जिसे अपडेट करना है. साथ ही, अपडेट के अनुरोध में omnichannelSetting फ़ील्ड में, उससे जुड़े फ़ील्ड भरने होंगे. इनमें से किसी भी फ़ील्ड को अपडेट किया जा सकता है:

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

अगर कोई एट्रिब्यूट, अपडेट मास्क में शामिल नहीं है, तो वह अपडेट नहीं होगा.

अगर कोई एट्रिब्यूट, अपडेट मास्क में शामिल है, लेकिन अनुरोध में सेट नहीं है, तो वह साफ़ हो जाएगा.

कोड का यह सैंपल, इन्वेंट्री की पुष्टि वाले फ़ील्ड को अपडेट करने का तरीका दिखाता है.

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)

इन्वेंट्री की पुष्टि का अनुरोध करना

omnichannelSettings.requestInventoryVerification सिर्फ़ GHLSF के व्यापारियों के लिए काम का है.

इस आरपीसी को कॉल करने से पहले, आपको ये काम करने होंगे:

  • प्रॉडक्ट और इन्वेंट्री डेटा अपलोड करना.
  • इन्वेंट्री की पुष्टि करने वाले व्यक्ति की पुष्टि करना.
  • ऑस्ट्रिया, जर्मनी या स्विट्ज़रलैंड में मौजूद व्यापारियों के लिए, an About पेज की समीक्षा पूरी करना.

ज़रूरी शर्तें पूरी करने की जानकारी पाने के लिए, omnichannelSettings.get को कॉल करें और omnichannelSetting.inventoryVerification.state की जांच करें. अगर इसमें INACTIVE दिखता है, तो 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);
  }
}

Omnichannel सेटिंग का स्टेटस देखना.

एलआईए ऑनबोर्डिंग की समीक्षाओं का स्टेटस देखने के लिए, ReviewState के संबंधित एट्रिब्यूट के लिए omnichannelSetting की जांच करें, जो omnichannelSettings.get या omnichannelSettings.list तरीकों से मिले हैं.

ReviewState फ़ील्ड, इन्वेंट्री की पुष्टि की प्रोसेस को छोड़कर, ऑनबोर्डिंग की सभी समीक्षाओं पर लागू होता है. इसमें ये वैल्यू हो सकती हैं:

  • ACTIVE: इसे मंज़ूरी मिल गई है.
  • FAILED: इसे अस्वीकार कर दिया गया है.
  • RUNNING: इसकी समीक्षा अभी जारी है.
  • ACTION_REQUIRED: यह सिर्फ़ GHLSF के व्यापारियों के लिए, InStock.state में दिखता है. इसका मतलब है कि एलआईए को चालू करने के लिए, आपको इन्वेंट्री की पुष्टि का अनुरोध करना होगा.

InventoryVerification.State में ये वैल्यू होती हैं:

  • SUCCEEDED: इसे मंज़ूरी मिल गई है.
  • INACTIVE: इन्वेंट्री की पुष्टि का अनुरोध किया जा सकता है.
  • RUNNING: इसकी समीक्षा जारी है
  • SUSPENDED: इन्वेंट्री की पुष्टि कई बार नहीं हो पाई है. आम तौर पर, पांच बार पुष्टि नहीं होने पर, आपको फिर से अनुरोध करने से पहले इंतज़ार करना होगा.
  • ACTION_REQUIRED: इन्वेंट्री की पुष्टि का अनुरोध करने से पहले, आपको कुछ और कार्रवाइयां करनी होंगी.

Omnichannel Settings API से जुड़ी समस्याओं को हल करना

इस सेक्शन में, आम तौर पर होने वाली समस्याओं को हल करने का तरीका बताया गया है.

Omnichannel सेटिंग बनाना

  • पक्का करें कि LsfType और RegionCode, दोनों सेट हों.
  • अगर GHLSF चुना जाता है, तो अनुरोध में InStock को खाली छोड़ें.
  • अगर व्यापारी के होस्ट किए गए एलएसएफ़ के टाइप चुने जाते हैं, तो InStock या Pickup में कम से कम एक यूआरआई दें.

Omnichannel सेटिंग अपडेट करना

इस संसाधन के लिए, अपडेट करने के तरीके में ये अतिरिक्त नियम लागू होते हैं:

  • रीजन कोड में बदलाव नहीं किया जा सकता.
  • एलआईए/एफ़्एलएल की सुविधा चालू होने या उसे मंज़ूरी मिलने के दौरान, अपडेट नहीं किए जा सकते.
  • व्यापारी के होस्ट किए गए एलएसएफ़ के टाइप से GHLSF पर स्विच करते समय, अगर InStock और Pickup पहले से कॉन्फ़िगर किए गए थे, तो आपको उन्हें अपडेट मास्क में, LsfType के अपडेट के साथ शामिल करना होगा.

उदाहरण के लिए, अगर आपने पहले MHLSF_BASIC और Pickup लागू किया था और उन्हें अस्वीकार कर दिया गया था, तो इस तरह का अनुरोध भेजकर, GHLSF पर स्विच किया जा सकता है:

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

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

इनकी जगह ये डालें:

  • {ACCOUNT_ID}: आपके Merchant Center खाते का यूनीक आइडेंटिफ़ायर
  • {REGION_CODE}: सीएलडीआर के मुताबिक तय किया गया रीजन कोड

इन्वेंट्री की पुष्टि का अनुरोध करना

प्रॉडक्ट या इन्वेंट्री फ़ीड अपडेट करने और संपर्क की पुष्टि करने के बावजूद, अगर InventoryVerification.state, INACTIVE के अलावा कोई और वैल्यू दिखाता है, तो:

  • ऑस्ट्रिया, जर्मनी, और स्विट्ज़रलैंड में मौजूद व्यापारियों के लिए: पक्का करें कि आपने 'इसके बारे में जानकारी' वाले पेज की समीक्षा पूरी कर ली हो.
  • इसमें करीब 48 घंटे की देरी होगी.
  • इन्वेंट्री की पुष्टि बार-बार नहीं हो पाने पर (पांच से ज़्यादा बार), सेवा, 30 दिनों का कूलिंग-डाउन पीरियड लागू करती है. इसके बाद ही, दूसरा अनुरोध किया जा सकता है. अगर आपको तय समय से पहले अनुरोध करना है, तो Google की सहायता टीम से संपर्क करें.

ज़्यादा जानें

ज़्यादा जानकारी के लिए, स्थानीय इन्वेंट्री विज्ञापनों और मुफ़्त में दिखाई जाने वाली स्थानीय लिस्टिंग का सहायता केंद्र देखें.