จัดการการตั้งค่าช่องทาง Omni

Omnichannel Settings API เป็นจุดเริ่มต้นในการกำหนดค่าโปรแกรมโฆษณาสินค้าคงคลังในร้าน (LIA) และข้อมูลในร้านที่แสดงฟรี (FLL)

ใช้เพื่อดำเนินการต่อไปนี้โดยทางโปรแกรม

  • จัดการ (สร้างและอัปเดต) การตั้งค่าช่องทาง Omni
  • ดึงข้อมูล (รับและแสดงรายการ) การตั้งค่าช่องทาง Omni
  • ขอรับการยืนยันสินค้าคงคลังสำหรับผู้ขายที่มีสิทธิ์

ดูข้อมูลเพิ่มเติมได้ที่ ภาพรวมของโฆษณาสินค้าคงคลังในร้านและข้อมูลในร้านที่แสดงฟรี

ข้อกำหนดเบื้องต้น

คุณควรมีสิ่งต่อไปนี้

  • บัญชี Merchant Center

  • Business Profile หากยังไม่มี คุณสามารถสร้างได้ ดูหัวข้อ ลงชื่อสมัครใช้ Business Profile

  • ลิงก์ระหว่าง Business Profile กับบัญชี Merchant Center หากต้องการสร้างลิงก์ คุณสามารถใช้อินเทอร์เฟซผู้ใช้ของ Merchant Center หรือ Merchant API (ดูหัวข้อลิงก์ Google Business Profile)

สร้างการตั้งค่าช่องทาง Omni

คุณสามารถใช้วิธี omnichannelSettings.create เพื่อสร้างการตั้งค่าช่องทาง Omni เมธอด create จะใช้ทรัพยากร omnichannelSetting เป็นอินพุตและแสดงผลการตั้งค่าช่องทาง Omni ที่สร้างขึ้น หากสำเร็จ

เมื่อสร้าง คุณต้องกรอกทั้ง regionCode และ the LsfType

  • OmnichannelSetting จะเป็นไปตามประเทศ RegionCode จะกำหนดประเทศเป้าหมาย เมื่อสร้างแล้ว คุณจะเปลี่ยนไม่ได้ RegionCode ควร เป็นไปตามกฎการตั้งชื่อที่กำหนดโดยโปรเจ็กต์ Common Locale Data Repository (CLDR)
  • LsfType จะอิงตามหน้าผลิตภัณฑ์ ดูรายละเอียดได้ที่ LsfType

ดูรายละเอียดเพิ่มเติมได้ที่ หัวข้อเปลี่ยนประสบการณ์การใช้งานหน้าผลิตภัณฑ์สำหรับโฆษณาสินค้าคงคลังในร้าน

คุณไม่จำเป็นต้องกรอกข้อมูลในทุกช่องในขั้นตอนการสร้าง แต่สามารถกำหนดค่าช่องเหล่านั้นในภายหลังได้ หากต้องการอัปเดต omnichannelSetting ที่มีอยู่ โปรดดู หัวข้ออัปเดตการตั้งค่าช่องทาง Omni

นี่คือตัวอย่างคำขอหากคุณเลือก 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}: URI ที่ถูกต้องซึ่งใช้สำหรับการตรวจสอบที่ระบุ URI ที่ไม่มีสิทธิ์อาจทำให้ไม่ได้รับการอนุมัติ

หลังจากคำขอทำงานสำเร็จ คุณควรเห็นการตอบกลับต่อไปนี้

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

การลงทะเบียนฟีเจอร์ LIA/FLL ต่างๆ โดยใช้ช่อง omnichannelSetting จะทริกเกอร์การตรวจสอบด้วยตนเอง ซึ่งโดยปกติจะใช้เวลา 2-3 ชั่วโมงถึง 2-3 วัน เราขอแนะนำให้ตรวจสอบข้อมูลที่ป้อนอีกครั้งเพื่อหลีกเลี่ยงเวลาที่ต้องรอโดยไม่จำเป็นเนื่องจากข้อมูลไม่มีสิทธิ์

หากต้องการดูการตั้งค่าช่องทาง Omni ที่สร้างขึ้นใหม่หรือตรวจสอบสถานะการตรวจสอบ ให้ใช้ accounts.omnichannelSettings.get หรือ accounts.omnichannelSettings.list โดยระบุประเทศ

ประเภทหน้าร้านในพื้นที่ (LSF)

เลือก LsfType ตามหน้าผลิตภัณฑ์ที่คุณวางแผนจะใช้

ประเภทหน้าผลิตภัณฑ์ LsfType ค่า Enum
หน้าสินค้าที่ระบุความพร้อมจำหน่ายสินค้าในร้าน หน้าร้านในพื้นที่ที่ผู้ขายโฮสต์แบบพื้นฐาน MHLSF_BASIC
หน้าสินค้าของร้านค้าที่เฉพาะเจาะจงพร้อมความพร้อมจำหน่ายสินค้าและราคา หน้าร้านในพื้นที่ที่ผู้ขายโฮสต์แบบสมบูรณ์ MHLSF_FULL
หน้าสินค้าที่ไม่ระบุความพร้อมจำหน่ายสินค้าในร้านค้า หน้าร้านในพื้นที่ที่ Google โฮสต์ (GHLSF) GHLSF

หากเลือกประเภทหน้าร้านในพื้นที่ที่ผู้ขายโฮสต์ คุณต้องกรอกข้อมูลในช่อง URI สำหรับ inStock หรือ pickup อย่างน้อย 1 ช่องด้วย

InStock

คุณสามารถใช้ InStock เพื่อให้ข้อมูลเพิ่มเติมเกี่ยวกับหน้าสินค้า

หากเลือกประเภทหน้าร้านในพื้นที่ที่ผู้ขายโฮสต์และระบุช่อง URI ใน InStock แสดงว่าคุณต้องการแสดงผลิตภัณฑ์ที่มีสินค้าพร้อมจำหน่าย เราจะเริ่มการตรวจสอบตาม URI ที่ระบุ

หากเลือกประเภท GHLSF คุณต้องระบุช่อง InStock ที่ว่างเปล่าในคำขอ คุณต้องทำตามกระบวนการยืนยันสินค้าคงคลังให้เสร็จสมบูรณ์จึงจะเริ่มต้นใช้งานได้ ซึ่งแตกต่างจากประเภทหน้าร้านในพื้นที่ที่ผู้ขายโฮสต์

ตัวอย่างโค้ดนี้จะสร้าง omnichannelSetting ด้วย GHLSF

Java

import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.CreateOmnichannelSettingRequest;
import com.google.shopping.merchant.accounts.v1.InStock;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting.LsfType;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/**
 * This class demonstrates how to create an omnichannel setting for a given Merchant Center account
 * in a given country
 */
public class CreateOmnichannelSettingSample {

  public static void createOmnichannelSetting(Config config, String regionCode) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
        OmnichannelSettingsServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Calls the API and catches and prints any network failures/errors.
    try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
        OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
      String accountId = config.getAccountId().toString();
      String parent = AccountName.newBuilder().setAccount(accountId).build().toString();

      // Creates an omnichannel setting with GHLSF type in the given country.
      CreateOmnichannelSettingRequest request =
          CreateOmnichannelSettingRequest.newBuilder()
              .setParent(parent)
              .setOmnichannelSetting(
                  OmnichannelSetting.newBuilder()
                      .setRegionCode(regionCode)
                      .setLsfType(LsfType.GHLSF)
                      .setInStock(InStock.getDefaultInstance())
                      .build())
              .build();

      System.out.println("Sending create omnichannel setting request:");
      OmnichannelSetting response =
          omnichannelSettingsServiceClient.createOmnichannelSetting(request);

      System.out.println("Inserted Omnichannel Setting below:");
      System.out.println(response);
    } catch (Exception e) {
      System.out.println("An error has occured: ");
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    // The country which you're targeting at.
    String regionCode = "{REGION_CODE}";

    createOmnichannelSetting(config, regionCode);
  }
}

PHP

use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\CreateOmnichannelSettingRequest;
use Google\Shopping\Merchant\Accounts\V1\InStock;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting;
use Google\Shopping\Merchant\Accounts\V1\OmnichannelSetting\LsfType;

/**
 * This class demonstrates how to create an omnichannel setting for a given
 * Merchant Center account in a given country.
 */
class CreateOmnichannelSetting
{
    /**
     * Helper to create the parent string.
     *
     * @param string $accountId The merchant account ID.
     * @return string The parent string in the format `accounts/{account}`.
     */
    private static function getParent(string $accountId): string
    {
        return sprintf('accounts/%s', $accountId);
    }

    /**
     * Creates an omnichannel setting for a given Merchant Center account.
     *
     * @param array $config The configuration file for authentication.
     * @param string $regionCode The country for the omnichannel setting.
     */
    public static function createOmnichannelSettingSample(
        array $config,
        string $regionCode
    ): void {
        // Obtains OAuth credentials from the configuration file.
        $credentials = Authentication::useServiceAccountOrTokenFile();

        // Creates a client.
        $omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
            'credentials' => $credentials
        ]);

        // Constructs the parent resource name.
        $parent = self::getParent($config['accountId']);

        // Creates the omnichannel setting with GHLSF type in the given country.
        $omnichannelSetting = new OmnichannelSetting([
            'region_code' => $regionCode,
            'lsf_type' => LsfType::GHLSF,
            'in_stock' => new InStock()
        ]);

        // Creates the request.
        $request = new CreateOmnichannelSettingRequest([
            'parent' => $parent,
            'omnichannel_setting' => $omnichannelSetting
        ]);

        // Calls the API and prints the response.
        try {
            printf("Sending create omnichannel setting request:%s", PHP_EOL);
            $response = $omnichannelSettingsServiceClient->createOmnichannelSetting($request);
            printf("Inserted Omnichannel Setting below:%s", PHP_EOL);
            print $response->serializeToJsonString(true) . PHP_EOL;
        } catch (ApiException $e) {
            printf("An error has occured: %s", $e->getMessage());
        }
    }

    /**
     * Executes the sample.
     */
    public function callSample(): void
    {
        $config = Config::generateConfig();
        // The country which you're targeting.
        $regionCode = '{REGION_CODE}';
        self::createOmnichannelSettingSample($config, $regionCode);
    }
}

// Runs the script.
$sample = new CreateOmnichannelSetting();
$sample->callSample();

Python

from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import CreateOmnichannelSettingRequest
from google.shopping.merchant_accounts_v1 import InStock
from google.shopping.merchant_accounts_v1 import OmnichannelSetting
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient


def create_omnichannel_setting(account_id: str, region_code: str) -> None:
  """Creates an omnichannel setting for a given Merchant Center account.

  Args:
      account_id: The ID of the Merchant Center account.
      region_code: The country for which you're creating the setting.
  """
  # Gets OAuth Credentials.
  credentials = generate_user_credentials.main()

  # Creates a client.
  client = OmnichannelSettingsServiceClient(credentials=credentials)

  # The parent account under which to create the setting.
  parent = f"accounts/{account_id}"

  # Creates an omnichannel setting with GHLSF type in the given country.
  omnichannel_setting = OmnichannelSetting()
  omnichannel_setting.region_code = region_code
  omnichannel_setting.lsf_type = OmnichannelSetting.LsfType.GHLSF
  omnichannel_setting.in_stock = InStock()

  # Creates the request.
  request = CreateOmnichannelSettingRequest(
      parent=parent, omnichannel_setting=omnichannel_setting
  )

  # Makes the request and catches and prints any error messages.
  try:
    print("Sending create omnichannel setting request:")
    response = client.create_omnichannel_setting(request=request)
    print("Inserted Omnichannel Setting below:")
    print(response)
  except RuntimeError as e:
    print("An error has occured: ")
    print(e)


if __name__ == "__main__":
  # The ID of the account to get the omnichannel settings for.
  _ACCOUNT = configuration.Configuration().read_merchant_info()

  # The country which you're targeting.
  _REGION_CODE = "{REGION_CODE}"

  create_omnichannel_setting(_ACCOUNT, _REGION_CODE)

รับที่ร้าน

นอกเหนือจากความพร้อมจำหน่ายสินค้าในร้านแล้ว คุณยังสามารถปรับปรุงผลิตภัณฑ์ในร้านด้วยฟีเจอร์การรับสินค้าที่ร้าน ซึ่งมีสิทธิ์ใช้ได้เฉพาะกับประเภทหน้าร้านในพื้นที่ที่ผู้ขายโฮสต์เท่านั้น

เมื่อมีการทำเครื่องหมายผลิตภัณฑ์ว่า "รับที่ร้าน" หมายความว่าลูกค้าสามารถซื้อผลิตภัณฑ์ทางออนไลน์และมารับที่ร้านได้ การตั้งค่าช่อง Pickup แสดงว่าคุณต้องการแสดงผลิตภัณฑ์ที่มี SLA สำหรับการรับสินค้า เราจะเริ่มการตรวจสอบตาม URI ที่ระบุ

นี่คือตัวอย่างคำขอที่สร้างการตั้งค่า 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 ไม่ได้จนกว่า URL ของหน้า "เกี่ยวกับ" จะได้รับการยืนยัน

สำหรับผู้ขายทั้งหมดใน 3 ประเทศนี้ บริการจะไม่เปิดใช้ฟีเจอร์ FLL/LIA จนกว่าหน้า "เกี่ยวกับ" จะได้รับการอนุมัติ

การยืนยันสินค้าคงคลัง

การยืนยันสินค้าคงคลังจำเป็นสำหรับผู้ขาย 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

ดูข้อมูลเพิ่มเติมเกี่ยวกับการตรวจสอบสถานะและความหมายของสถานะได้ที่หัวข้อดู สถานะของการตั้งค่าช่องทาง Omni

แสดงรายการการตั้งค่าช่องทาง Omni

หากต้องการดึงข้อมูล 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)

อัปเดตการตั้งค่าช่องทาง Omni

หากต้องการอัปเดตการกำหนดค่าของการตั้งค่าช่องทาง Omni ที่มีอยู่ ให้ใช้วิธี 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 เท่านั้น

คุณต้องดำเนินการต่อไปนี้ให้เสร็จสมบูรณ์ก่อนที่จะเรียก RPC นี้

  • อัปโหลดข้อมูลผลิตภัณฑ์และข้อมูลสินค้าคงคลัง
  • ยืนยันผู้ติดต่อสำหรับการยืนยันสินค้าคงคลัง
  • สำหรับผู้ขายในออสเตรีย เยอรมนี หรือสวิตเซอร์แลนด์ ให้ทำการตรวจสอบหน้า 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);
  }
}

ดูสถานะของการตั้งค่าช่องทาง Omni

หากต้องการตรวจสอบสถานะการตรวจสอบการเริ่มต้นใช้งาน LIA ให้ตรวจสอบ ReviewState สำหรับแอตทริบิวต์ที่เกี่ยวข้องของ omnichannelSetting ที่แสดงผลโดย omnichannelSettings.get หรือ omnichannelSettings.list เมธอด

ช่อง ReviewState ใช้กับการตรวจสอบการเริ่มต้นใช้งานทั้งหมด ยกเว้นกระบวนการยืนยันสินค้าคงคลัง และอาจมีค่าต่อไปนี้

  • ACTIVE: ได้รับการอนุมัติ
  • FAILED: ถูกปฏิเสธ
  • RUNNING: อยู่ระหว่างการตรวจสอบ
  • ACTION_REQUIRED: สถานะนี้มีเฉพาะใน InStock.state สำหรับผู้ขาย GHLSF ซึ่งหมายความว่าคุณต้องขอรับการยืนยันสินค้าคงคลังเพื่อให้ LIA แสดง

InventoryVerification.State มีค่าต่อไปนี้

  • SUCCEEDED: ได้รับการอนุมัติ
  • INACTIVE: คุณพร้อมที่จะขอรับการยืนยันสินค้าคงคลังแล้ว
  • RUNNING: อยู่ระหว่างการตรวจสอบ
  • SUSPENDED: คุณไม่ผ่านการยืนยันสินค้าคงคลังหลายครั้งเกินไป (โดยปกติคือ 5 ครั้ง) และต้องรอสักครู่ก่อนจึงจะขออีกครั้งได้
  • ACTION_REQUIRED: คุณต้องดำเนินการเพิ่มเติมก่อนที่จะขอรับการยืนยันสินค้าคงคลัง

แก้ปัญหาที่เกี่ยวข้องกับ Omnichannel Settings API

ส่วนนี้อธิบายวิธีแก้ปัญหาที่พบบ่อย

สร้างการตั้งค่าช่องทาง Omni

  • ตรวจสอบว่าได้ตั้งค่าทั้ง LsfType และ RegionCode แล้ว
  • หากเลือก GHLSF ให้ระบุ InStock ที่ว่างเปล่าในคำขอ
  • หากเลือกประเภทหน้าร้านในพื้นที่ที่ผู้ขายโฮสต์ ให้ระบุ URI อย่างน้อย 1 รายการใน InStock หรือ Pickup

อัปเดตการตั้งค่าช่องทาง Omni

เมธอดอัปเดตสำหรับทรัพยากรนี้ต้องเป็นไปตามกฎเพิ่มเติมต่อไปนี้

  • คุณไม่สามารถแก้ไขรหัสภูมิภาคได้
  • คุณไม่สามารถทำการอัปเดตขณะที่ฟีเจอร์ 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 แม้ว่าคุณจะอัปเดตฟีดผลิตภัณฑ์หรือฟีดสินค้าคงคลังและยืนยันผู้ติดต่อแล้วก็ตาม ให้ทำดังนี้

  • สำหรับผู้ขายในออสเตรีย เยอรมนี และสวิตเซอร์แลนด์: ตรวจสอบว่าคุณได้ทำการตรวจสอบหน้า "เกี่ยวกับ" ให้เสร็จสมบูรณ์แล้ว
  • ระบบจะใช้เวลาประมาณ 48 ชั่วโมง
  • ในกรณีที่การตรวจสอบสินค้าคงคลังล้มเหลวซ้ำๆ (มากกว่า 5 ครั้ง) บริการจะบังคับใช้ระยะเวลาพัก 30 วันก่อนที่จะอนุญาตให้ส่งคำขออีกครั้ง โปรดติดต่อทีมสนับสนุนของ Google หากต้องการส่งคำขอก่อนหน้านี้

ดูข้อมูลเพิ่มเติม

ดูรายละเอียดเพิ่มเติมได้ที่ ศูนย์ช่วยเหลือของโฆษณาสินค้าคงคลังในร้านและข้อมูลในร้านที่แสดงฟรี