Omnichannel Settings API เป็นจุดแรกเข้าสำหรับการกำหนดค่าโปรแกรมโฆษณาสินค้าคงคลังในร้าน (LIA) และข้อมูลในร้านที่แสดงฟรี (FLL)
ใช้เพื่อดำเนินการต่อไปนี้แบบเป็นโปรแกรม
- จัดการ (สร้างและอัปเดต) การตั้งค่า Omnichannel
- ดึงข้อมูล (รับและแสดงรายการ) การตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง
- ขอรับการยืนยันสินค้าคงคลังสำหรับผู้ขายที่มีสิทธิ์
ดูข้อมูลเพิ่มเติมได้ที่ภาพรวมของโฆษณาสินค้าคงคลังในร้านและข้อมูลในร้านที่แสดงฟรี
ข้อกำหนดเบื้องต้น
คุณควรมี
บัญชี Merchant Center
Business Profile หากยังไม่มีบัญชี คุณก็สร้างใหม่ได้ ดูหัวข้อลงชื่อสมัครใช้ Business Profile
การลิงก์ระหว่าง Business Profile กับบัญชี Merchant Center หากต้องการสร้างลิงก์ คุณสามารถใช้อินเทอร์เฟซผู้ใช้ของ Merchant Center หรือ Merchant API (ดูหัวข้อลิงก์ Google Business Profile)
สร้างการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel)
คุณสามารถใช้เมธอด omnichannelSettings.create เพื่อสร้างการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง เมธอด create จะใช้ทรัพยากร omnichannelSetting เป็นอินพุตและแสดงผลการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทางที่สร้างขึ้น หากดำเนินการสำเร็จ
เมื่อสร้าง คุณต้องกรอกทั้ง regionCode และ LsfType ดังนี้
- OmnichannelSetting จะใช้เป็นรายประเทศ
RegionCodeกำหนดประเทศเป้าหมาย เมื่อสร้างแล้ว คุณจะเปลี่ยนแปลงไม่ได้RegionCodeควรเป็นไปตามกฎการตั้งชื่อที่กำหนดโดยโปรเจ็กต์ Common Locale Data Repository (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}: 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 วัน เราขอแนะนำให้ตรวจสอบข้อมูลที่ป้อนอีกครั้งเพื่อหลีกเลี่ยงเวลารอที่ไม่จำเป็นเนื่องจากข้อมูลไม่มีสิทธิ์
หากต้องการดูการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทางที่สร้างขึ้นใหม่หรือตรวจสอบสถานะการตรวจสอบ ให้ใช้ accounts.omnichannelSettings.get หรือ accounts.omnichannelSettings.list โดยระบุประเทศ
ประเภทหน้าร้านในพื้นที่ (LSF)
เลือกLsfTypeตามหน้าผลิตภัณฑ์ที่คุณวางแผนจะใช้ ดังนี้
| ประเภทหน้าสินค้า | LsfType | ค่า enum |
|---|---|---|
| หน้าสินค้าที่ระบุความพร้อมจำหน่ายสินค้าในร้าน | หน้าร้านในพื้นที่ที่ผู้ขายโฮสต์ (แบบพื้นฐาน) | MHLSF_BASIC |
| หน้าสินค้าของร้านค้าที่เฉพาะเจาะจงพร้อมความพร้อมจำหน่ายสินค้าและราคา | หน้าร้านในพื้นที่ที่ผู้ขายโฮสต์แบบสมบูรณ์ | MHLSF_FULL |
| หน้าสินค้าที่ไม่มีความพร้อมจำหน่ายที่หน้าร้าน | หน้าร้านในพื้นที่ที่ Google โฮสต์ (GHLSF) | GHLSF |
หากเลือกประเภทหน้าร้านในพื้นที่ที่ผู้ขายโฮสต์ คุณจะต้องกรอกข้อมูลในช่อง URI สำหรับ inStock หรือ pickup อย่างน้อย 1 รายการด้วย
InStock
คุณใช้ InStock เพื่อให้ข้อมูลเพิ่มเติมเกี่ยวกับหน้าสินค้าได้
หากเลือกประเภท LSF ที่ผู้ขายโฮสต์และระบุช่อง URI ใน InStock แสดงว่าคุณต้องการแสดงผลิตภัณฑ์ที่มีความพร้อมจำหน่ายสินค้าแบบมีสินค้าพร้อมจำหน่าย เราจะเริ่มตรวจสอบตาม URI ที่ระบุ
หากเลือกประเภท GHLSF คุณต้องระบุช่อง InStock ที่ว่างเปล่าในคำขอ คุณต้องทำกระบวนการยืนยันสินค้าคงคลังให้เสร็จสมบูรณ์เพื่อเริ่มต้นใช้งาน ซึ่งแตกต่างจากประเภท LSF ที่ผู้ขายโฮสต์
ตัวอย่างโค้ดนี้จะสร้าง 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)
รับที่ร้าน
นอกเหนือจากความพร้อมจำหน่ายที่หน้าร้านแล้ว คุณยังปรับปรุงผลิตภัณฑ์ในร้านได้ด้วยฟีเจอร์การรับสินค้า ซึ่งใช้ได้กับ LSF ประเภทที่ผู้ขายโฮสต์เท่านั้น
เมื่อผลิตภัณฑ์มีการทำเครื่องหมายว่า "รับสินค้า" หมายความว่าลูกค้าสามารถซื้อผลิตภัณฑ์ทางออนไลน์และมารับที่ร้านค้าได้ การตั้งค่าช่อง 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 Search จะเห็นสินค้าเหล่านี้มีการทำเครื่องหมายเป็น "พร้อมสำหรับการสั่งซื้อ"
ลูกค้าสามารถเลือกโฆษณาสินค้าคงคลังในร้านหรือข้อมูลในร้านที่แสดงฟรีเพื่อดูสินค้าดังกล่าวได้ เมื่อต้องการซื้อสินค้า ลูกค้าจะไปยังหน้าร้านจริง ดูสินค้า จากนั้นสั่งซื้อสินค้าให้จัดส่งไปที่บ้านหรือส่งไปที่ร้านแล้วมารับสินค้าเองก็ได้
เกี่ยวกับ (เยอรมนี ออสเตรีย และสวิตเซอร์แลนด์)
หากแสดงโฆษณาในออสเตรียและเยอรมนีและเลือก 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
ดูข้อมูลเพิ่มเติมเกี่ยวกับสถานะการตรวจสอบและความหมายได้ที่ดูสถานะของการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง
แสดงรายการการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel)
หากต้องการดึงข้อมูล omnichannelSetting ทั้งหมดสำหรับบัญชีของคุณ ให้ใช้เมธอด omnichannelSettings.list
ตัวอย่างโค้ดมีดังนี้
Java
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.ListOmnichannelSettingsRequest;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient.ListOmnichannelSettingsPagedResponse;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to get the list of omnichannel settings for a given Merchant Center
* account
*/
public class ListOmnichannelSettingsSample {
public static void omnichannelSettings(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String accountId = config.getAccountId().toString();
String parent = AccountName.newBuilder().setAccount(accountId).build().toString();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
ListOmnichannelSettingsRequest request =
ListOmnichannelSettingsRequest.newBuilder().setParent(parent).build();
System.out.println("Sending list omnichannel setting request:");
ListOmnichannelSettingsPagedResponse response =
omnichannelSettingsServiceClient.listOmnichannelSettings(request);
int count = 0;
// Iterates over all the entries in the response.
for (OmnichannelSetting omnichannelSetting : response.iterateAll()) {
System.out.println(omnichannelSetting);
count++;
}
System.out.println(String.format("The following count of elements were returned: %d", count));
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
omnichannelSettings(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\OmnichannelSettingsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\ListOmnichannelSettingsRequest;
/**
* This class demonstrates how to get the list of omnichannel settings for a
* given Merchant Center account.
*/
class ListOmnichannelSettings
{
/**
* Helper to create the parent string.
*
* @param string $accountId The merchant account ID.
* @return string The parent string in the format `accounts/{account}`.
*/
private static function getParent(string $accountId): string
{
return sprintf('accounts/%s', $accountId);
}
/**
* Lists the omnichannel settings for a given Merchant Center account.
*
* @param array $config The configuration file for authentication.
*/
public static function listOmnichannelSettingsSample(array $config): void
{
// Obtains OAuth credentials from the configuration file.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Creates a client.
$omnichannelSettingsServiceClient = new OmnichannelSettingsServiceClient([
'credentials' => $credentials
]);
// Constructs the parent resource name.
$parent = self::getParent($config['accountId']);
// Creates the request.
$request = new ListOmnichannelSettingsRequest(['parent' => $parent]);
// Calls the API and prints the response.
try {
printf("Sending list omnichannel setting request:%s", PHP_EOL);
$response = $omnichannelSettingsServiceClient->listOmnichannelSettings($request);
$count = 0;
// Iterates over all the omnichannel settings and prints them.
foreach ($response->iterateAllElements() as $omnichannelSetting) {
print $omnichannelSetting->serializeToJsonString(true) . PHP_EOL;
$count++;
}
printf("The following count of elements were returned: %d%s", $count, PHP_EOL);
} catch (ApiException $e) {
printf("An error has occured: %s", $e->getMessage());
}
}
/**
* Executes the sample.
*/
public function callSample(): void
{
$config = Config::generateConfig();
self::listOmnichannelSettingsSample($config);
}
}
// Runs the script.
$sample = new ListOmnichannelSettings();
$sample->callSample();
Python
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import ListOmnichannelSettingsRequest
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
def list_omnichannel_settings(account_id: str) -> None:
"""Lists the omnichannel settings for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The parent account for which to list the settings.
parent = f"accounts/{account_id}"
# Creates the request.
request = ListOmnichannelSettingsRequest(parent=parent)
# Makes the request and catches and prints any error messages.
try:
print("Sending list omnichannel setting request:")
response = client.list_omnichannel_settings(request=request)
count = 0
# Iterates over all the entries in the response.
for omnichannel_setting in response:
print(omnichannel_setting)
count += 1
print(f"The following count of elements were returned: {count}")
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
list_omnichannel_settings(_ACCOUNT)
อัปเดตการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel)
หากต้องการอัปเดตการกำหนดค่าของการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทางที่มีอยู่ ให้ใช้เมธอด omnichannelSettings.update
หากต้องการอัปเดต คุณต้องเพิ่มฟีเจอร์ที่ต้องการลงในมาสก์การอัปเดต และกรอกข้อมูลในช่องที่เกี่ยวข้องในช่อง omnichannelSetting ในคำขออัปเดต
คุณอัปเดตข้อมูลเหล่านี้ได้ทุกเมื่อ
lsfTypeinStockpickupodoaboutinventoryVerification
หากแอตทริบิวต์ไม่ได้รวมอยู่ในมาสก์การอัปเดต ระบบจะไม่อัปเดตแอตทริบิวต์ดังกล่าว
หากแอตทริบิวต์รวมอยู่ในมาสก์การอัปเดต แต่ไม่ได้ตั้งค่าในคำขอ ระบบจะล้างแอตทริบิวต์นั้น
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีอัปเดตช่องการยืนยันสินค้าคงคลัง
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);
}
}
ดูสถานะของการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง
หากต้องการตรวจสอบสถานะการตรวจสอบของการเริ่มต้นใช้งาน 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
ส่วนนี้จะอธิบายวิธีแก้ปัญหาที่พบบ่อย
สร้างการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel)
- อย่าลืมตั้งค่าทั้ง
LsfTypeและRegionCode - หากเลือก
GHLSFให้ระบุInStockที่ว่างเปล่าในคำขอ - หากเลือกประเภท LSF ที่ผู้ขายโฮสต์ ให้ระบุ URI อย่างน้อย 1 รายการใน
InStockหรือPickup
อัปเดตการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel)
วิธีการอัปเดตสำหรับทรัพยากรนี้ต้องใช้กฎเพิ่มเติมต่อไปนี้
- คุณแก้ไขรหัสภูมิภาคไม่ได้
- คุณจะอัปเดตไม่ได้ขณะที่ฟีเจอร์ LIA/FLL ทำงานอยู่หรือได้รับอนุมัติแล้ว
- เมื่อเปลี่ยนจากประเภท LSF ที่ผู้ขายโฮสต์เป็น
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 หากต้องการขอรับการชำระเงินก่อนกำหนด
ดูข้อมูลเพิ่มเติม
ดูรายละเอียดเพิ่มเติมได้ที่ศูนย์ช่วยเหลือเกี่ยวกับโฆษณาสินค้าคงคลังในร้านและข้อมูลในร้านที่แสดงฟรี