رابط برنامهنویسی کاربردی تنظیمات همهکاناله (Omnichannel Settings API) نقطه ورود به پیکربندی برنامههای تبلیغات موجودی محلی (LIA) و فهرستهای محلی رایگان (FLL) شماست.
از آن به صورت برنامهنویسی استفاده کنید
- مدیریت (ایجاد و بهروزرسانی) تنظیمات Omnichannel
- تنظیمات همه کاناله (Omnichannel) را دریافت و فهرست کنید
- درخواست تأیید موجودی برای فروشندگان واجد شرایط
برای اطلاعات بیشتر، به آگهیهای موجودی محلی و نمای کلی فهرستهای محلی رایگان مراجعه کنید.
پیشنیازها
باید داشتی.
یک حساب مرکز تجاری
یک نمایه تجاری. اگر ندارید، میتوانید یکی ایجاد کنید. به بخش «ثبتنام برای نمایه تجاری» مراجعه کنید.
پیوندی بین نمایه تجاری شما و حساب مرکز فروشندگان شما. برای ایجاد پیوند، میتوانید از رابط کاربری مرکز فروشندگان یا رابط برنامهنویسی کاربردی فروشندگان استفاده کنید ( به پیوند نمایه تجاری گوگل مراجعه کنید).
ایجاد تنظیمات همه کاناله
شما میتوانید از متد omnichannelSettings.create برای ایجاد یک تنظیمات omnichannel استفاده کنید. متد create یک منبع omnichannelSetting را به عنوان ورودی دریافت میکند و در صورت موفقیت، تنظیمات omnichannel ایجاد شده را برمیگرداند.
هنگام ایجاد، باید هم regionCode و هم LsfType را وارد کنید:
- تنظیمات Omnichannel بر اساس هر کشور انجام میشود.
RegionCodeکشور هدف را تعریف میکند. پس از ایجاد، نمیتوانید آن را تغییر دهید.RegionCodeباید از قانون نامگذاری تعریف شده توسط پروژه مخزن دادههای محلی مشترک (CLDR) پیروی کند. -
LsfTypeبر اساس صفحه محصول شما است. برای جزئیات بیشتر، بهLsfTypeمراجعه کنید.
برای جزئیات بیشتر، به تغییر تجربه صفحه محصول برای تبلیغات موجودی محلی خود مراجعه کنید.
لازم نیست همه فیلدها را در مرحله ایجاد پر کنید، بلکه میتوانید بعداً آنها را پیکربندی کنید. برای بهروزرسانی omnichannelSetting موجود، به بهروزرسانی تنظیمات omnichannel مراجعه کنید.
در اینجا یک نمونه درخواست برای انتخاب 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}: شناسه منحصر به فرد حساب مرکز فروش شما -
{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 باعث بررسیهای دستی میشود که معمولاً به چند ساعت تا چند روز زمان نیاز دارند. توصیه میکنیم ورودیهای خود را دوباره بررسی کنید تا از زمان انتظار غیرضروری به دلیل دادههای نامناسب جلوگیری شود.
برای مشاهده تنظیمات omnichannel تازه ایجاد شده یا بررسی وضعیت نظرات، accounts.omnichannelSettings.get یا accounts.omnichannelSettings.list با مشخص کردن کشور استفاده کنید.
نوع ویترین فروشگاه محلی (LSF)
بر اساس صفحه محصولی که قصد استفاده از آن را دارید، یک LsfType انتخاب کنید:
| نوع صفحه محصول | نوع LSF | مقدار شمارشی |
|---|---|---|
| صفحات محصول با قابلیت نمایش در فروشگاه | نمای فروشگاه محلی میزبان فروشنده پایه | MHLSF_BASIC |
| صفحات محصولات خاص فروشگاه با موجودی و قیمت | فروشگاه محلی با میزبانی فروشنده، نمای کامل فروشگاه | MHLSF_FULL |
| صفحات محصول بدون موجودی در فروشگاه | فروشگاه محلی تحت میزبانی گوگل (GHLSF) | GHLSF |
اگر انواع فروشگاه محلی با میزبانی فروشنده (Merchant-hosted) را انتخاب میکنید، باید فیلد URI را برای حداقل یکی از گزینههای موجود inStock یا pickup نیز پر کنید.
موجود در انبار
شما میتوانید از InStock برای ارائه اطلاعات بیشتر در مورد صفحه محصول خود استفاده کنید.
اگر انواع LSF میزبان-فروشگاهی را انتخاب کنید و فیلد URI را در InStock مشخص کنید، قصد خود را برای ارائه محصولاتی با موجودی موجود در انبار نشان میدهید. ما بر اساس URI ارائه شده، بررسی را آغاز خواهیم کرد.
اگر نوع GHLSF را انتخاب کنید، باید یک فیلد خالی در قسمت InStock در درخواست ارائه دهید. برخلاف انواع LSF میزبانیشده توسط فروشنده، برای تکمیل فرآیند ثبتنام، باید فرآیند تأیید موجودی را تکمیل کنید.
این نمونه کد یک omnichannelSetting با GHLSF ایجاد میکند:
جاوا
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.CreateOmnichannelSettingRequest;
import com.google.shopping.merchant.accounts.v1.InStock;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting.LsfType;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to create an omnichannel setting for a given Merchant Center account
* in a given country
*/
public class CreateOmnichannelSettingSample {
public static void createOmnichannelSetting(Config config, String regionCode) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String parent = AccountName.newBuilder().setAccount(accountId).build().toString();
// Creates an omnichannel setting with GHLSF type in the given country.
CreateOmnichannelSettingRequest request =
CreateOmnichannelSettingRequest.newBuilder()
.setParent(parent)
.setOmnichannelSetting(
OmnichannelSetting.newBuilder()
.setRegionCode(regionCode)
.setLsfType(LsfType.GHLSF)
.setInStock(InStock.getDefaultInstance())
.build())
.build();
System.out.println("Sending create omnichannel setting request:");
OmnichannelSetting response =
omnichannelSettingsServiceClient.createOmnichannelSetting(request);
System.out.println("Inserted Omnichannel Setting below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
createOmnichannelSetting(config, regionCode);
}
}
پی اچ پی
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();
پایتون
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 میزبان فروشنده (Merchant-hosted LSF) واجد شرایط است، ارتقا دهید.
وقتی محصولی برای تحویل گرفتن علامتگذاری میشود، به این معنی است که مشتری میتواند آن را به صورت آنلاین خریداری کرده و در فروشگاه تحویل بگیرد. با تنظیم فیلد Pickup ، شما قصد خود را برای ارائه محصولات با SLA تحویل گرفتن نشان میدهید. ما بر اساس URI ارائه شده، بررسی را شروع خواهیم کرد.
در اینجا یک درخواست نمونه وجود دارد که با Pickup یک تنظیمات omnichannel ایجاد میکند:
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings
{
"regionCode": "{REGION_CODE}",
"lsfType: "MHLSF_BASIC",
"pickup": {
"uri: "{URI}"
}
}
قابل نمایش برای سفارش
با قابلیت نمایش سفارش ، میتوانید محصولاتی را که در فروشگاه فیزیکی شما نمایش داده میشوند اما برای خرید فوری در دسترس نیستند، نمایش دهید. به عنوان مثال، مبلمان بزرگ:
- مشتریانی که به دنبال محصولات مشابه در گوگل هستند، این تبلیغات را با حاشیهنویسی «در فروشگاه» در نتایج جستجوی خود مشاهده خواهند کرد.
- مشتریانی که در صفحه نتایج جستجوی گوگل در حال مرور فروشگاه هستند، این محصولات را با علامت «موجود برای سفارش» مشاهده خواهند کرد.
آنها میتوانند آگهی موجودی محلی یا فهرست محلی رایگان شما را برای مشاهده کالا انتخاب کنند. برای خرید کالا، میتوانند از فروشگاه فیزیکی شما دیدن کنند، کالا را مشاهده کنند و سپس سفارش دهند که برای آنها ارسال شود یا برای تحویل گرفتن به فروشگاه شما ارسال شود.
درباره (آلمان، اتریش و سوئیس)
اگر در اتریش و آلمان خدمت میکنید و GHLSF انتخاب میکنید، باید یک صفحه «درباره ما » ارسال کنید.
اگر در سوئیس خدمت میکنید، صرف نظر از LsfType ، باید یک صفحه «درباره ما» ارسال کنید.
تا زمانی که آدرس اینترنتی صفحه «درباره ما» تأیید نشود، فروشندگان GHLSF نمیتوانند از گوگل درخواست تأیید دستی موجودی کنند.
برای همه فروشندگان در این سه کشور، این سرویس ویژگیهای FLL/LIA را تا زمانی که صفحه «درباره ما» شما تأیید نشود، فعال نمیکند.
تأیید موجودی
تأیید موجودی فقط برای فروشندگان GHLSF الزامی است. این مورد برای انواع MHLSF پشتیبانی نمیشود.
قبل یا بعد از اضافه کردن دادههای محصول و دادههای موجودی (چه با استفاده از accounts.products.localInventories.insert و چه با استفاده از رابط کاربری مرکز فروشندگان)، باید مخاطب خود را تأیید کنید. با استفاده از متد create یا update ، یک مخاطب تأیید موجودی (نام و آدرس ایمیل) ارائه دهید. مخاطب ایمیلی از طرف گوگل دریافت میکند و میتواند با کلیک روی دکمهای در پیام، وضعیت خود را تأیید کند.
پس از تکمیل این مرحله، میتوانید درخواست تأیید موجودی کالا را بدهید . برای اطلاعات بیشتر به «درباره تأیید موجودی کالا» مراجعه کنید.
شما میتوانید مخاطب خود را در طول فرآیند تأیید یا پس از تأیید با استفاده از omnichannelSetting.update تغییر دهید.
پس از اتمام این فرآیند، گوگل صحت اطلاعات ارائه شده را تأیید میکند.
یک تنظیم omnichannel دریافت کنید
برای بازیابی پیکربندی omnichannelSetting در یک کشور مشخص، یا بررسی وضعیت فعلی نظرات خود، از متد omnichannelSettings.get استفاده کنید.
در اینجا یک نمونه درخواست آمده است:
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/omnichannelSettings/{OMNICHANNEL_SETTING}
موارد زیر را جایگزین کنید:
-
{ACCOUNT_ID}: شناسه منحصر به فرد حساب مرکز فروش شما -
{OMNICHANNEL_SETTING}: کد منطقه کشور مورد نظر شما
وضعیت ACTIVE نشان میدهد که بررسی تأیید شده است.
اگر وضعیت FAILED است، با فراخوانی omnichannelSetting.update ، مشکلات را برطرف کرده و یک بررسی جدید را آغاز کنید.
فیلد LFP فقط خواندنی، وضعیت مشارکت فیدهای محلی شما را نشان میدهد. برای پیوند به این مشارکت، از lfpProviders.linkLfpProvider استفاده کنید.
برای اطلاعات بیشتر در مورد بررسی وضعیتها و معانی آنها، به مشاهده وضعیت تنظیمات omnichannel مراجعه کنید.
تنظیمات Omnichannel را فهرست کنید
برای بازیابی تمام اطلاعات omnichannelSetting برای حساب کاربری خود، از متد omnichannelSettings.list استفاده کنید.
این هم یک نمونه کد:
جاوا
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AccountName;
import com.google.shopping.merchant.accounts.v1.ListOmnichannelSettingsRequest;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient.ListOmnichannelSettingsPagedResponse;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to get the list of omnichannel settings for a given Merchant Center
* account
*/
public class ListOmnichannelSettingsSample {
public static void omnichannelSettings(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String accountId = config.getAccountId().toString();
String parent = AccountName.newBuilder().setAccount(accountId).build().toString();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
ListOmnichannelSettingsRequest request =
ListOmnichannelSettingsRequest.newBuilder().setParent(parent).build();
System.out.println("Sending list omnichannel setting request:");
ListOmnichannelSettingsPagedResponse response =
omnichannelSettingsServiceClient.listOmnichannelSettings(request);
int count = 0;
// Iterates over all the entries in the response.
for (OmnichannelSetting omnichannelSetting : response.iterateAll()) {
System.out.println(omnichannelSetting);
count++;
}
System.out.println(String.format("The following count of elements were returned: %d", count));
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
omnichannelSettings(config);
}
}
پی اچ پی
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();
پایتون
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
برای بهروزرسانی پیکربندی یک تنظیمات omnichannel موجود، از متد omnichannelSettings.update استفاده کنید.
برای بهروزرسانی، باید ویژگی مورد نظر خود را به ماسک بهروزرسانی اضافه کنید و فیلدهای مربوطه را در فیلد omnichannelSetting در درخواست بهروزرسانی پر کنید. میتوانید هر یک از موارد زیر را بهروزرسانی کنید:
-
lsfType -
inStock -
pickup -
odo -
about -
inventoryVerification
اگر یک ویژگی در ماسک بهروزرسانی گنجانده نشده باشد، بهروزرسانی نخواهد شد.
اگر یک ویژگی در ماسک بهروزرسانی گنجانده شده باشد، اما در درخواست تنظیم نشده باشد، پاک خواهد شد.
نمونه کد زیر نحوه بهروزرسانی فیلد تأیید موجودی را نشان میدهد.
جاوا
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.protobuf.FieldMask;
import com.google.shopping.merchant.accounts.v1.InventoryVerification;
import com.google.shopping.merchant.accounts.v1.OmnichannelSetting;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.UpdateOmnichannelSettingRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to update an omnichannel setting for a given Merchant Center account
* in a given country
*/
public class UpdateOmnichannelSettingSample {
public static void updateOmnichannelSettings(
Config config, String regionCode, String contact, String email) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String name =
OmnichannelSettingName.newBuilder()
.setAccount(accountId)
.setOmnichannelSetting(regionCode)
.build()
.toString();
OmnichannelSetting omnichannelSetting =
OmnichannelSetting.newBuilder()
.setName(name)
.setInventoryVerification(
InventoryVerification.newBuilder()
.setContact(contact)
.setContactEmail(email)
.build())
.build();
FieldMask fieldMask = FieldMask.newBuilder().addPaths("inventory_verification").build();
UpdateOmnichannelSettingRequest request =
UpdateOmnichannelSettingRequest.newBuilder()
.setOmnichannelSetting(omnichannelSetting)
.setUpdateMask(fieldMask)
.build();
System.out.println("Sending update omnichannel setting request:");
OmnichannelSetting response =
omnichannelSettingsServiceClient.updateOmnichannelSetting(request);
System.out.println("Updated Omnichannel Setting below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
// The name of the inventory verification contact you want to update.
String contact = "{NAME}";
// The address of the inventory verification email you want to update.
String email = "{EMAIL}";
updateOmnichannelSettings(config, regionCode, contact, email);
}
}
پی اچ پی
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();
پایتون
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.protobuf import field_mask_pb2
from google.shopping.merchant_accounts_v1 import InventoryVerification
from google.shopping.merchant_accounts_v1 import OmnichannelSetting
from google.shopping.merchant_accounts_v1 import OmnichannelSettingsServiceClient
from google.shopping.merchant_accounts_v1 import (
UpdateOmnichannelSettingRequest,
)
def update_omnichannel_setting(
account_id: str, region_code: str, contact: str, email: str
) -> None:
"""Updates an omnichannel setting for a given Merchant Center account.
Args:
account_id: The ID of the Merchant Center account.
region_code: The country for which you're updating the setting.
contact: The name of the inventory verification contact.
email: The email of the inventory verification contact.
"""
# Gets OAuth Credentials.
credentials = generate_user_credentials.main()
# Creates a client.
client = OmnichannelSettingsServiceClient(credentials=credentials)
# The name of the omnichannel setting to update.
name = f"accounts/{account_id}/omnichannelSettings/{region_code}"
# Creates an omnichannel setting with the updated values.
omnichannel_setting = OmnichannelSetting()
omnichannel_setting.name = name
omnichannel_setting.inventory_verification = InventoryVerification(
contact=contact, contact_email=email
)
# Creates a field mask to specify which fields to update.
field_mask = field_mask_pb2.FieldMask(paths=["inventory_verification"])
# Creates the request.
request = UpdateOmnichannelSettingRequest(
omnichannel_setting=omnichannel_setting, update_mask=field_mask
)
# Makes the request and catches and prints any error messages.
try:
print("Sending update omnichannel setting request:")
response = client.update_omnichannel_setting(request=request)
print("Updated Omnichannel Setting below:")
print(response)
except RuntimeError as e:
print("An error has occured: ")
print(e)
if __name__ == "__main__":
# The ID of the account to get the omnichannel settings for.
_ACCOUNT = configuration.Configuration().read_merchant_info()
# The country which you're targeting.
_REGION_CODE = "{REGION_CODE}"
# The name of the inventory verification contact you want to update.
_CONTACT = "{NAME}"
# The address of the inventory verification email you want to update.
_EMAIL = "{EMAIL}"
update_omnichannel_setting(_ACCOUNT, _REGION_CODE, _CONTACT, _EMAIL)
درخواست تأیید موجودی
omnichannelSettings.requestInventoryVerification فقط مربوط به بازرگانان GHLSF است.
قبل از اینکه این RPC را فراخوانی کنید، باید موارد زیر را انجام داده باشید:
- اطلاعات محصول و موجودی خود را بارگذاری کنید.
- یک مخاطب تأیید موجودی را تأیید کنید.
- برای بازرگانان در اتریش، آلمان یا سوئیس، یک بررسی صفحه
About» را تکمیل کنید.
برای تعیین واجد شرایط بودن خود، omnichannelSettings.get را فراخوانی کنید و omnichannelSetting.inventoryVerification.state را بررسی کنید. اگر INACTIVE را نشان داد، آماده فراخوانی omnichannelSettings.requestInventoryVerification هستید.
جاوا
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingName;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceClient;
import com.google.shopping.merchant.accounts.v1.OmnichannelSettingsServiceSettings;
import com.google.shopping.merchant.accounts.v1.RequestInventoryVerificationRequest;
import com.google.shopping.merchant.accounts.v1.RequestInventoryVerificationResponse;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to request inventory verification for a given Merchant Center account
* in a given country
*/
public class RequestInventoryVerificationSample {
public static void requestInventoryVerification(Config config, String regionCode)
throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
// Creates service settings using the credentials retrieved above.
OmnichannelSettingsServiceSettings omnichannelSettingsServiceSettings =
OmnichannelSettingsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Calls the API and catches and prints any network failures/errors.
try (OmnichannelSettingsServiceClient omnichannelSettingsServiceClient =
OmnichannelSettingsServiceClient.create(omnichannelSettingsServiceSettings)) {
String accountId = config.getAccountId().toString();
String name =
OmnichannelSettingName.newBuilder()
.setAccount(accountId)
.setOmnichannelSetting(regionCode)
.build()
.toString();
RequestInventoryVerificationRequest request =
RequestInventoryVerificationRequest.newBuilder().setName(name).build();
System.out.println("Sending request inventory verification request:");
RequestInventoryVerificationResponse response =
omnichannelSettingsServiceClient.requestInventoryVerification(request);
System.out.println("Omnichannel Setting after inventory verification request below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The country which you're targeting at.
String regionCode = "{REGION_CODE}";
requestInventoryVerification(config, regionCode);
}
}
وضعیت تنظیمات omnichannel را مشاهده کنید.
برای بررسی وضعیت بررسیهای مربوط به ثبتنام اولیه در LIA، ReviewState ، ویژگیهای متناظر omnichannelSetting که توسط متدهای omnichannelSettings.get یا omnichannelSettings.list برگردانده میشوند را بررسی کنید.
فیلد ReviewState به جز فرآیند تأیید موجودی، برای همه بررسیهای ورود به سیستم اعمال میشود و میتواند مقادیر زیر را داشته باشد:
-
ACTIVE: مورد تایید است. -
FAILED: رد شده است. -
RUNNING: هنوز در دست بررسی است. -
ACTION_REQUIRED: این مورد فقط درInStock.stateبرای فروشندگان GHLSF وجود دارد. این بدان معناست که برای ارائه خدمات LIA، باید درخواست تأیید موجودی بدهید.
InventoryVerification.State دارای مقادیر زیر است:
-
SUCCEEDED: تصویب شد. -
INACTIVE: شما آماده درخواست تأیید موجودی هستید. -
RUNNING: در دست بررسی است -
SUSPENDED: شما بارها (معمولاً ۵ بار) در تأیید موجودی شکست خوردهاید و باید صبر کنید تا بتوانید دوباره آن را درخواست کنید. -
ACTION_REQUIRED: قبل از درخواست تأیید موجودی، باید اقدامات دیگری انجام دهید.
عیبیابی مشکلات مربوط به Omnichannel Settings API
این بخش نحوه عیبیابی مشکلات رایج را شرح میدهد.
ایجاد تنظیمات همه کاناله
- مطمئن شوید که هر دو
LsfTypeوRegionCodeرا تنظیم کردهاید. - اگر
GHLSFرا انتخاب میکنید، در درخواست، یکInStockخالی ارائه دهید. - اگر انواع LSF میزبان-فروشگاهی را انتخاب میکنید، حداقل یک URI در
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}: شناسه منحصر به فرد حساب مرکز فروش شما -
{REGION_CODE}: کد منطقه به صورت CLDR تعریف شده
درخواست تأیید موجودی
اگر، علیرغم بهروزرسانی فیدهای محصول یا موجودی و تأیید مخاطب، InventoryVerification.state INACTIVE باشد:
- برای بازرگانان در اتریش، آلمان و سوئیس: مطمئن شوید که بررسی صفحه «درباره ما» را تکمیل کردهاید.
- حدود ۴۸ ساعت تاخیر خواهد داشت.
- در صورت تکرار خطای بررسی موجودی (بیش از پنج بار)، سرویس قبل از اجازه دادن به درخواست دیگر، یک دوره زمانی سی روزه برای رفع مشکل اعمال میکند. اگر میخواهید زودتر درخواست دهید، با پشتیبانی گوگل تماس بگیرید.
بیشتر بدانید
برای جزئیات بیشتر، به مرکز راهنمایی آگهیهای موجودی محلی و فهرستهای محلی رایگان مراجعه کنید.