مدیریت تنظیمات «چندکانالی»

Omnichannel Settings API نقطه ورود برای پیکربندی برنامه‌های «آگهی‌های فهرست موجودی محلی» (LIA) و «فهرستگان‌های محلی رایگان» (FLL) است.

از آن برای برنامه‌نویسی استفاده کنید

  • مدیریت (ایجاد و به‌روزرسانی) تنظیمات Omnichannel
  • واکشی (دریافت و فهرست کردن) تنظیمات Omnichannel
  • درخواست درستی‌سنجی فهرست موجودی برای فروشندگان واجدشرایط

برای اطلاعات بیشتر، نمای کلی آگهی‌های فهرست موجودی محلی و فهرستگان‌های محلی رایگان را ببینید.

پیش‌نیازها

باید داشته باشید

ایجاد تنظیمات همه‌کاناله

می‌توانید از روش omnichannelSettings.create برای ایجاد تنظیمات همه‌کاناله استفاده کنید. روش ایجاد، منبع omnichannelSetting را به‌عنوان ورودی می‌گیرد و درصورت موفقیت، تنظیمات همه‌کاناله ایجادشده را برمی‌گرداند.

هنگام ایجاد، باید هم regionCode و هم LsfType را پر کنید:

  • OmnichannelSetting براساس هر کشور است. RegionCode کشور موردهدف را تعریف می‌کند. پس‌از ایجاد، نمی‌توانید آن را تغییر دهید. ‫RegionCode باید از قانون نام‌گذاری تعریف‌شده توسط پروژه مخزن داده‌های محلی مشترک (CLDR) پیروی کند.
  • LsfType براساس صفحه محصول شما است. برای جزئیات، به LsfType مراجعه کنید.

برای جزئیات بیشتر، تغییر تجربه صفحه محصول برای آگهی‌های فهرست موجودی محلی را ببینید.

لازم نیست همه فیلدها را در مرحله ایجاد تکمیل کنید، اما می‌توانید بعداً آن‌ها را پیکربندی کنید. برای به‌روزرسانی omnichannelSetting موجود، به‌روزرسانی تنظیمات همه‌کاناله را ببینید.

در اینجا یک درخواست نمونه آورده شده است اگر بخواهید 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}: کد منطقه طبق تعریف CLDR
  • {URI}: شناسه منبع یکسان معتبری که برای مرور ارائه‌شده استفاده شده است. شناسه منبع یکسان نامعتبر ممکن است مانع تأیید شود.

پس‌از اجرای موفقیت‌آمیز درخواست، باید پاسخ زیر را ببینید:

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

ثبت‌نام ویژگی‌های مختلف «آگهی‌های موجودی محلی»/ «فهرستگان محلی ویترین فروشگاه» بااستفاده از فیلدهای omnichannelSetting، بازبینی‌های دستی را راه‌اندازی می‌کند که معمولاً چند ساعت تا چند روز طول می‌کشد. توصیه می‌کنیم ورودی‌هایتان را دوباره بررسی کنید تا به‌دلیل داده‌های نامعتبر، زمان انتظار غیرضروری نداشته باشید.

برای مشاهده تنظیمات همه‌کاناله جدیداً ایجادشده یا بررسی وضعیت بازبینی‌ها، از accounts.omnichannelSettings.get یا accounts.omnichannelSettings.list استفاده کنید و کشور را مشخص کنید.

نوع ویترین فروشگاه محلی (LSF)

براساس صفحه محصولی که قصد دارید استفاده کنید، LsfType را انتخاب کنید:

نوع صفحه محصول LsfType مقدار Enum
صفحه‌های محصول با موجودی کالا در فروشگاه ویترین فروشگاه محلی پایه با میزبانی فروشنده MHLSF_BASIC
صفحه‌های محصول مختص فروشگاه با موجودی و قیمت ویترین فروشگاه محلی کامل با میزبانی فروشنده MHLSF_FULL
صفحه‌های محصول بدون موجودی کالا در فروشگاه ویترین فروشگاه محلی به‌میزبانی Google (GHLSF) GHLSF

اگر انواع ویترین فروشگاه محلی به میزبانی فروشنده را انتخاب کنید، باید فیلد URI را برای حداقل یکی از inStock یا pickup تکمیل کنید.

InStock

می‌توانید از InStock برای ارائه اطلاعات بیشتر درباره صفحه محصولتان استفاده کنید.

اگر انواع «صفحه فرود فروشگاه با میزبانی فروشنده» را انتخاب کنید و فیلد URI را در InStock مشخص کنید، قصد خود را برای ارائه محصولات با دردسترس بودن موجود در انبار نشان می‌دهید. براساس شناسه منبع یکسان ارائه‌شده، بازبینی را شروع خواهیم کرد.

اگر نوع GHLSF را انتخاب کنید، باید فیلد InStock خالی را در درخواست ارائه دهید. برخلاف انواع «فهرست‌های فروشگاه محلی با میزبانی فروشنده»، برای تکمیل آماده‌سازی، باید فرایند درستی‌سنجی فهرست موجودی را تکمیل کنید.

این نمونه کد یک omnichannelSetting با GHLSF ایجاد می‌کند:

جاوا

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، نشان می‌دهید که قصد دارید محصولات را با «قرارداد سطح خدمات» تحویل در محل ارائه دهید. براساس شناسه منبع یکسان ارائه‌شده، بازبینی را شروع خواهیم کرد.

در اینجا یک درخواست نمونه آورده شده است که تنظیم omnichannel را با Pickup ایجاد می‌کند:

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 یا میانای کاربر «مرکز فروشندگان»)، باید مخاطب خود را به‌تأیید برسانید. بااستفاده از روش create یا update، اطلاعات تماس (نام و نشانی ایمیل) برای درستی‌سنجی فهرست موجودی ارائه دهید. مخاطب ایمیلی ازطرف Google دریافت می‌کند و می‌تواند با کلیک کردن روی دکمه‌ای در پیام، وضعیت خود را به‌تأیید برساند.

وقتی این کار را تکمیل کردید، می‌توانید درخواست درستی‌سنجی فهرست موجودی کنید. برای اطلاعات بیشتر، درباره درستی‌سنجی فهرست موجودی را ببینید.

می‌توانید اطلاعات تماستان را درطول فرایند درستی‌سنجی یا پس‌از درستی‌سنجی بااستفاده از omnichannelSetting.update تغییر دهید.

پس‌از تکمیل این فرایند، Google صحت اطلاعات ارائه‌شده را اعتبارسنجی می‌کند.

دریافت تنظیمات همه‌کاناله

برای بازیابی پیکربندی 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 استفاده کنید.

برای اطلاعات بیشتر درباره بررسی وضعیت‌ها و معانی آن‌ها، به مشاهده وضعیت تنظیمات همه‌کاناله مراجعه کنید.

فهرست کردن تنظیمات چندکاناله

برای بازیابی همه اطلاعات omnichannelSetting برای حسابتان، از روش omnichannelSettings.list استفاده کنید.

در اینجا یک نمونه کد آورده شده است:

جاوا

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)

به‌روزرسانی تنظیمات همه‌کاناله

برای به‌روزرسانی پیکربندی تنظیمات همه‌کاناله موجود، از روش omnichannelSettings.update استفاده کنید.

برای به‌روزرسانی، باید ویژگی موردنظرتان را به ماسک به‌روزرسانی اضافه کنید و فیلدهای مربوطه را در فیلد omnichannelSetting در درخواست به‌روزرسانی تکمیل کنید. می‌توانید هرکدام از موارد زیر را به‌روز کنید

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

اگر مشخصه‌ای در ماسک به‌روزرسانی گنجانده نشده باشد، به‌روزرسانی نخواهد شد.

اگر مشخصه‌ای در ماسک به‌روزرسانی گنجانده شده باشد اما در درخواست تنظیم نشده باشد، پاک خواهد شد.

نمونه کد زیر نحوه به‌روزرسانی فیلد درستی‌سنجی فهرست موجودی را نشان می‌دهد.

جاوا

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 مربوط می‌شود.

قبل‌از فراخوانی این RPC، باید موارد زیر را انجام داده باشید:

  • داده‌های محصول و موجودی‌تان را بارگذاری کنید.
  • درستی‌سنجی کردن مخاطب درستی‌سنجی فهرست موجودی.
  • برای فروشندگان در آلمان، اتریش، یا سوئیس، بازبینی صفحه About را تکمیل کنید.

برای تعیین واجدشرایط بودن، با omnichannelSettings.get تماس بگیرید و omnichannelSetting.inventoryVerification.state را بررسی کنید. اگر INACTIVE را نشان می‌دهد، برای تماس با omnichannelSettings.requestInventoryVerification آماده‌اید.

جاوا

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);
  }
}

مشاهده وضعیت تنظیمات همه‌کاناله.

برای بررسی وضعیت بازبینی بازبینی‌های آماده‌سازی LIA، ReviewState را برای مشخصه‌های متناظر omnichannelSetting که توسط روش‌های omnichannelSettings.get یا omnichannelSettings.list برگردانده شده‌اند بررسی کنید.

فیلد ReviewState برای همه بازبینی‌های آماده‌سازی به‌جز فرایند درستی‌سنجی فهرست موجودی اعمال می‌شود و می‌تواند مقادیر زیر را داشته باشد:

  • ‫ACTIVE: تأیید شده است.
  • ‫FAILED: رد شده است.
  • RUNNING: هنوز دردست مرور است.
  • ‫ACTION_REQUIRED: این فقط در InStock.state برای فروشندگان GHLSF وجود دارد. یعنی باید برای نمایش آگهی‌های موجودی محلی، درخواست درستی‌سنجی فهرست موجودی بدهید.

InventoryVerification.State مقادیر زیر را دارد:

  • ‫SUCCEEDED: تأیید شده است.
  • INACTIVE: برای درخواست درستی‌سنجی فهرست موجودی آماده‌اید.
  • RUNNING: زیر حد مرور است
  • SUSPENDED: درستی‌سنجی فهرست موجودی شما دفعات زیادی (معمولاً ۵ بار) ناموفق بوده است و باید مدتی صبر کنید تا بتوانید دوباره آن را درخواست کنید.
  • ACTION_REQUIRED: قبل‌از درخواست درستی‌سنجی فهرست موجودی، باید اقدامات بیشتری انجام دهید.

عیب‌یابی کردن مشکلات مربوط به Omnichannel Settings API

این بخش نحوه عیب‌یابی کردن مشکلات رایج را شرح می‌دهد.

ایجاد تنظیمات همه‌کاناله

  • حتماً هر دو LsfType و RegionCode را تنظیم کنید.
  • اگر GHLSF را انتخاب کنید، InStock خالی در درخواست ارائه دهید.
  • اگر انواع «صفحه فروشگاه محلی با میزبانی فروشنده» را انتخاب می‌کنید، حداقل یک شناسه منبع یکسان در InStock یا Pickup ارائه دهید.

به‌روزرسانی تنظیمات همه‌کاناله

روش به‌روزرسانی برای این منبع به قوانین تکمیلی زیر نیاز دارد:

  • نمی‌توانید کد منطقه را اصلاح کنید.
  • وقتی ویژگی «آگهی‌های موجودی محلی»/«فهرستگان محلی رایگان» درحال اجرا است یا تأیید شده است، نمی‌توانید به‌روزرسانی انجام دهید.
  • هنگام تغییر از انواع «فروشگاه محلی با میزبانی فروشنده» به 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}: کد منطقه طبق تعریف CLDR

درخواست درستی‌سنجی فهرست موجودی

اگر، باوجود به‌روزرسانی فیدهای محصول یا موجودی و تأیید مخاطب، InventoryVerification.state چیزی غیراز INACTIVE باشد:

  • برای فروشندگان در آلمان، اتریش، و سوئیس: مطمئن شوید که مرور صفحه «درباره» را تکمیل کرده‌اید.
  • حدود ۴۸ ساعت تأخیر وجود خواهد داشت.
  • درصورت تکرار ناموفق بودن «بررسی موجودی» (بیش‌از پنج بار)، سرویس پیش‌از اجازه دادن به درخواست دیگر، دوره استراحت سی روزه اعمال می‌کند. اگر می‌خواهید زودتر درخواست دهید، با «پشتیبانی Google» تماس بگیرید.

بیشتر بدانید

برای جزئیات بیشتر، به مرکز راهنمایی آگهی‌های فهرست موجودی محلی و فهرستگان‌های محلی رایگان مراجعه کنید.