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

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

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

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

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

پیش‌نیازها

باید

ایجاد تنظیمات چندکانالی

می‌توانید از روش 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"
  }
}

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

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

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

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

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

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

InStock

می‌توانید از 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 درخواست درستی‌سنجی دستی موجودی کند.

برای همه فروشندگان در این سه کشور، تا زمانی که صفحه «درباره» شما تأیید نشود، این سرویس ویژگی‌های FLL/LIA را فعال نمی‌کند.

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

«درستی‌سنجی فهرست موجودی» فقط برای فروشندگان GHLSF الزامی است. برای انواع MHLSF پشتیبانی نمی‌شود.

چه قبل‌از افزودن داده‌های محصول و داده‌های موجودی (بااستفاده از accounts.products.localInventories.insert یا میانای کاربر Merchant Center) و چه بعداز آن، باید مخاطب خود را به‌تأیید برسانید. بااستفاده از روش 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 وجود دارد. یعنی برای ارائه کردن LIA، باید درخواست درستی‌سنجی موجودی کنید.

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

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

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

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

ایجاد تنظیمات چندکانالی

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

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

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

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

بیشتر بدانید

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