Omnichannel Settings API เป็นจุดเริ่มต้นในการกำหนดค่าโปรแกรมโฆษณาสินค้าคงคลังในร้าน (LIA) และข้อมูลในร้านที่แสดงฟรี (FLL)
ใช้เพื่อดำเนินการต่อไปนี้โดยอัตโนมัติ
- จัดการ (สร้างและอัปเดต) การตั้งค่าช่องทาง Omni
- ดึงข้อมูล (รับและแสดงรายการ) การตั้งค่า Omnichannel
- ขอรับการยืนยันสินค้าคงคลังสำหรับผู้ขายที่มีสิทธิ์
ดูข้อมูลเพิ่มเติมได้ที่ภาพรวมของโฆษณาสินค้าคงคลังในร้านและข้อมูลในร้านที่แสดงฟรี
ข้อกำหนดเบื้องต้น
คุณควรมี
บัญชี Merchant Center
Business Profile หากยังไม่มีบัญชี คุณก็สร้างบัญชีได้ ดูลงชื่อสมัครใช้ Business Profile
ลิงก์ระหว่าง Business Profile กับบัญชี Merchant Center หากต้องการสร้างลิงก์ คุณสามารถใช้อินเทอร์เฟซผู้ใช้ Merchant Center หรือ Merchant API (ดูลิงก์ Google Business Profile)
สร้างการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel)
คุณสามารถใช้เมธอด omnichannelSettings.create เพื่อสร้างการตั้งค่า
Omnichannel ได้ เมธอด create รับทรัพยากร omnichannelSetting เป็นอินพุตและ
จะแสดงผลการตั้งค่า Omnichannel ที่สร้างขึ้น หากสำเร็จ
เมื่อสร้าง คุณต้องกรอกทั้งregionCodeและ
LsfType
- OmnichannelSetting จะเป็นแบบต่อประเทศ
RegionCodeจะกำหนด ประเทศเป้าหมาย เมื่อสร้างแล้ว คุณจะเปลี่ยนแปลงไม่ได้RegionCodeควร ทำตามกฎการตั้งชื่อที่กำหนดโดยโปรเจ็กต์ที่เก็บข้อมูลภาษาทั่วไป (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 วัน เราขอแนะนำให้คุณตรวจสอบข้อมูลที่ป้อนอีกครั้งเพื่อหลีกเลี่ยงเวลาในการรอที่ไม่จำเป็นเนื่องจากข้อมูลไม่มีสิทธิ์
หากต้องการดูการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel) ที่สร้างขึ้นใหม่หรือตรวจสอบสถานะของรีวิว
ให้ใช้ 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จะเป็นอย่างไรก็ตาม
จนกว่า URL ของหน้า "เกี่ยวกับ" จะได้รับการยืนยัน GHLSF ผู้ขายจะขอรับการยืนยันสินค้าคงคลังด้วยตนเองจาก Google ไม่ได้
สำหรับผู้ขายทั้งหมดใน 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)
แสดงการตั้งค่า 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);
}
}
ดูสถานะของการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง (Omnichannel)
หากต้องการตรวจสอบสถานะการตรวจสอบการเริ่มต้นใช้งาน 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
อัปเดตการตั้งค่าการเข้าถึงลูกค้าจากทุกช่องทาง
วิธีการอัปเดตสำหรับทรัพยากรนี้ต้องมีกฎเพิ่มเติมต่อไปนี้
- คุณแก้ไขรหัสภูมิภาคไม่ได้
- คุณจะทำการอัปเดตขณะที่ฟีเจอร์ 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 หากต้องการขอรับเงินคืนก่อนกำหนด
ดูข้อมูลเพิ่มเติม
ดูรายละเอียดเพิ่มเติมได้ที่ ศูนย์ช่วยเหลือเกี่ยวกับโฆษณาสินค้าคงคลังในร้านและข้อมูลในร้านที่แสดงฟรี