بهبودهای خودکار مجموعهای از ویژگیها است که به Google اجازه میدهد محصولات، تصاویر، و برآوردهای ارسال شما را براساس صفحه مقصد وبسایتتان بهطور خودکار بهروز کند. فعال کردن این بهبودهای خودکار میتواند به بهبود تجربه کاربری، ترافیک بیشتر به محصولات شما، و نرخ تبدیل بالاتر منجر شود.
میتوانید از منبع
AutomaticImprovements
در زیررابط برنامهسازی کاربردی «حسابها» برای موارد زیر استفاده کنید:
- تنظیمات فعلی بهبود خودکار را برای حساب Merchant Center خود مشاهده کنید.
- بهروزرسانیهای خودکار را برای قیمت، دردسترس بودن، و وضعیت محصول فعال یا غیرفعال کنید. برای اطلاعات بیشتر، درباره بهروزرسانیهای خودکار مورد را ببینید.
- فعال یا غیرفعال کردن اصلاح خودکار تصویر. برای اطلاعات بیشتر، به Merchant Center اجازه دهید تصاویر محصولتان را بهبود بخشد را ببینید.
- بهبودهای خودکار در برآورد ارسال کالا را فعال یا غیرفعال کنید. برای اطلاعات بیشتر درباره برآوردهای ارسال خودکار، به میخواهم Google سرعت ارسال من را براساس شرکت حملونقل من محاسبه کند مراجعه کنید.
ملاحظات ویژه
- توارث تنظیمات:
- تنظیمات
itemUpdates(بهروزرسانیهای خودکار محصول) وimageImprovements(بهبودهای خودکار تصویر) میتوانند از حساب پیشرفته به حسابهای فرعی منتقل شوند. تنظیمات خاص حساب فرعی جایگزین تنظیمات موروثی میشود. - تنظیمات
shippingImprovements(بهبودهای خودکار ارسال) قابلانتقال نیستند و برای حسابهای پیشرفته اعمال نمیشوند.
- تنظیمات
- رابط کاربری Merchant Center:
shippingImprovementsفقط ازطریق API قابلمدیریت است، نه ازطریق رابط کاربری Merchant Center.
- رفتار بهروزرسانی:
- هنگام بهروزرسانی تنظیمات برای
itemUpdates،imageImprovements، یاshippingImprovements، میانای برنامهسازی کاربردی جایگزینی کامل مؤلفه سطح بالای مشخصشده را انجام میدهد (برای مثال، کل شیءitemUpdates). تأیید کنید که درخواست بهروزرسانی شما شامل همه زیرفیلدهای موردنظر برای مؤلفههایی است که قصد دارید تغییر دهید، همانطور که توسطupdate_maskمشخص شده است.
- هنگام بهروزرسانی تنظیمات برای
- پیشنیازها:
- قبلاز فعال کردن بهروزرسانی خودکار مورد، مطمئن شوید که دادههای ساختاریافته را در وبسایتتان راهاندازی کردهاید.
بازیابی تنظیمات بهبودهای خودکار
تنظیمات بهبود خودکار فعلی را برای حساب Merchant Center خود بازیابی کنید. این شامل تنظیمات بهروزرسانیهای مورد (قیمت، دردسترس بودن، وضعیت)، بهبودهای تصویر، و بهبودهای ارسال میشود. پاسخ هم تنظیماتی را که مستقیماً در حساب پیکربندی شدهاند (درصورت وجود) و هم تنظیمات مؤثر را نشان میدهد که وراثت از حساب پیشرفته را برای بهروزرسانیهای مورد و تصویر درنظر میگیرد.
GET https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/automaticImprovements
درخواست موفق منبع AutomaticImprovements را در بدنه پاسخ برمیگرداند. پاسخ هم تنظیمات پیکربندیشده مستقیماً در حساب
و هم تنظیمات مؤثر را نشان میدهد. تنظیمات effective همان تنظیماتی است که بر حساب اعمال میشود و اگر بهطور صریح تنظیم نشده باشد، ممکن است از حساب سطح بالاتر (مانند حساب چندمشتری) به ارث برده شود.
{
"name": "accounts/{ACCOUNT_ID}/automaticImprovements",
// Example 1: Settings are directly configured on the account.
"itemUpdates": {
// When `accountItemUpdatesSettings` is present, `effective` values match the configured ones.
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": false,
"allowConditionUpdates": true
},
"effectiveAllowPriceUpdates": true,
"effectiveAllowAvailabilityUpdates": true,
"effectiveAllowStrictAvailabilityUpdates": false,
"effectiveAllowConditionUpdates": true
},
// Example 2: Settings are inherited from a parent account.
"imageImprovements": {
// `accountImageImprovementsSettings` is omitted, thus the `effective` value of `true` is inherited.
"effectiveAllowAutomaticImageImprovements": true
},
"shippingImprovements": {
"accountShippingImprovementsSettings": {
"allowShippingImprovements": true
},
"effectiveAllowShippingImprovements": true
}
}
این مثال نشان میدهد که چگونه تنظیمات بهبود خودکار را برای یک حساب Merchant Center بازیابی کنید.
جاوا
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovements;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovementsName;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovementsServiceClient;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovementsServiceSettings;
import com.google.shopping.merchant.accounts.v1.GetAutomaticImprovementsRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to get the automatic improvements of a Merchant Center account. */
public class GetAutomaticImprovementsSample {
public static void getAutomaticImprovements(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.
AutomaticImprovementsServiceSettings automaticImprovementsServiceSettings =
AutomaticImprovementsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates AutomaticImprovements name to identify the AutomaticImprovements.
String name =
AutomaticImprovementsName.newBuilder()
.setAccount(config.getAccountId().toString())
.build()
.toString();
// Calls the API and catches and prints any network failures/errors.
try (AutomaticImprovementsServiceClient automaticImprovementsServiceClient =
AutomaticImprovementsServiceClient.create(automaticImprovementsServiceSettings)) {
// The name has the format: accounts/{account}/automaticImprovements
GetAutomaticImprovementsRequest request =
GetAutomaticImprovementsRequest.newBuilder().setName(name).build();
System.out.println("Sending get AutomaticImprovements request:");
AutomaticImprovements response =
automaticImprovementsServiceClient.getAutomaticImprovements(request);
System.out.println("Retrieved AutomaticImprovements below");
System.out.println(response);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
getAutomaticImprovements(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Shopping\Merchant\Accounts\V1\Client\AutomaticImprovementsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\GetAutomaticImprovementsRequest;
/**
* This class demonstrates how to get the automatic improvements of a Merchant Center account.
*/
class GetAutomaticImprovementsSample
{
/**
* Helper function to construct the resource name for AutomaticImprovements.
*
* @param string $accountId The Merchant Center account ID.
* @return string The resource name in the format: accounts/{account}/automaticImprovements
*/
private static function getAutomaticImprovementsName(string $accountId): string
{
return sprintf("accounts/%s/automaticImprovements", $accountId);
}
/**
* Retrieves the automatic improvements settings for a given Merchant Center account.
*
* @param array $config The configuration array containing the account ID.
* @return void
*/
public static function getAutomaticImprovementsSample(array $config): void
{
// Obtains OAuth credentials for authentication.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Contructs an options array for the client.
$options = ['credentials' => $credentials];
// Creates a new AutomaticImprovementsServiceClient.
$automaticImprovementsServiceClient = new AutomaticImprovementsServiceClient($options);
// Constructs the full resource name for the automatic improvements settings.
$name = self::getAutomaticImprovementsName($config['accountId']);
// Creates the GetAutomaticImprovementsRequest.
$request = new GetAutomaticImprovementsRequest(['name' => $name]);
printf("Sending get AutomaticImprovements request:%s", PHP_EOL);
try {
// Makes the API call to retrieve automatic improvements settings.
$response = $automaticImprovementsServiceClient->getAutomaticImprovements($request);
printf("Retrieved AutomaticImprovements below%s", PHP_EOL);
// Prints the response in JSON format for readability.
print_r($response);
} catch (ApiException $e) {
printf("ApiException was thrown: %s%s", $e->getMessage(), PHP_EOL);
}
}
/**
* Helper to execute the sample.
*
* @return void
*/
public function callSample(): void
{
$config = Config::generateConfig();
self::getAutomaticImprovementsSample($config);
}
}
// Runs the script.
$sample = new GetAutomaticImprovementsSample();
$sample->callSample();
Python
"""Gets the automatic improvements settings for a Merchant Center account."""
from examples.authentication import configuration
from examples.authentication import generate_user_credentials
from google.shopping.merchant_accounts_v1 import AutomaticImprovementsServiceClient
from google.shopping.merchant_accounts_v1 import GetAutomaticImprovementsRequest
# Fetches the account ID from the config file.
# This is a placeholder for your actual account ID.
_ACCOUNT_ID = configuration.Configuration().read_merchant_info()
# Construct the resource name for AutomaticImprovements.
# The format is accounts/{account}/automaticImprovements
_NAME = f"accounts/{_ACCOUNT_ID}/automaticImprovements"
def get_automatic_improvements_sample():
"""Gets the automatic improvements settings for a Merchant Center account."""
# Generates OAuth 2.0 credentials for authentication.
credentials = generate_user_credentials.main()
# Creates a client for the AutomaticImprovementsService.
client = AutomaticImprovementsServiceClient(credentials=credentials)
# Creates the request to get automatic improvements.
# The name parameter is the resource name of the automatic improvements
# settings.
request = GetAutomaticImprovementsRequest(name=_NAME)
print("Sending get AutomaticImprovements request:")
# Makes the API request to get automatic improvements.
try:
response = client.get_automatic_improvements(request=request)
print("Retrieved AutomaticImprovements below")
print(response)
except RuntimeError as e:
print(f"An API error occurred: {e}")
if __name__ == "__main__":
get_automatic_improvements_sample()
cURL
curl --location \
'https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/automaticImprovements' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
بهروز کردن تنظیمات بهبودهای خودکار
تنظیمات بهبود خودکار را برای حساب Merchant Center خود اصلاح کنید.
شیء AutomaticImprovements را با وضعیت موردنظر برای
itemUpdates، imageImprovements، و shippingImprovements ارائه دهید. از پارامتر پُرسمان
update_mask برای مشخص کردن فیلدهایی که بهروز میکنید استفاده کنید (برای مثال، برای بهروز کردن همه تنظیمات ارائهشده، از update_mask=* استفاده کنید).
وقتی تنظیمات را بهروز میکنید، میتوانید پیکربندی موجود را رونویسی کنید یا آن را پاک کنید تا تنظیمات را از حساب ولی به ارث ببرید.
برای بازنویسی تنظیم: نام فیلد سطح بالا (برای مثال،
itemUpdatesیاimageImprovements) را درupdate_maskاضافه کنید و پیکربندی جدید آن را در بدنه درخواست ارائه دهید. این کنش هرگونه تنظیمات موجود برای آن فیلد را در حساب فرعی جایگزین میکند.برای پاک کردن تنظیم و بهارث بردن از والد: نام فیلد را در
update_maskاضافه کنید، اما فیلد را کاملاً از بدنه درخواست حذف کنید. با این کار، پیکربندی خاص از حساب فرعی برداشته میشود و باعث میشود تنظیمات را از حساب اصلیاش بهارث ببرد. اگر حساب ولی هم تنظیمات پیکربندیشدهای نداشته باشد، پیشفرض سیستم اعمال میشود.
مثال زیر نشان میدهد که چگونه تنظیمات imageImprovements را برای یک حساب فرعی پاک کنید تا آن را از حساب اصلی خود به ارث ببرد، درحالیکه بهطور همزمان تنظیمات itemUpdates را بهروزرسانی میکنید.
PATCH https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/automaticImprovements?update_mask=itemUpdates,imageImprovements
بدنه درخواست (imageImprovements حذف میشود):
{
"name": "accounts/{ACCOUNT_ID}/automaticImprovements",
"itemUpdates": {
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": true,
"allowConditionUpdates": true
}
}
}
PATCH https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/automaticImprovements?update_mask=itemUpdates,imageImprovements,shippingImprovements
نمونه بدنه درخواست (فعال کردن همه بهبودها):
{
"name": "accounts/{ACCOUNT_ID}/automaticImprovements",
"itemUpdates": {
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": true,
"allowConditionUpdates": true
}
},
"imageImprovements": {
"accountImageImprovementsSettings": {
"allowAutomaticImageImprovements": true
}
},
"shippingImprovements": {
"allowShippingImprovements": true
}
}
درخواست موفق منبع AutomaticImprovements بهروزشده را در بدنه پاسخ برمیگرداند.
{
"name": "accounts/{ACCOUNT_ID}/automaticImprovements",
"itemUpdates": {
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": true,
"allowConditionUpdates": true
},
"effectiveAllowPriceUpdates": true,
"effectiveAllowAvailabilityUpdates": true,
"effectiveAllowStrictAvailabilityUpdates": true,
"effectiveAllowConditionUpdates": true
},
"imageImprovements": {
"accountImageImprovementsSettings": {
"allowAutomaticImageImprovements": true
},
"effectiveAllowAutomaticImageImprovements": true
},
"shippingImprovements": {
"allowShippingImprovements": true
"effectiveAllowShippingImprovements": true
}
}
این مثال نحوه بهروزرسانی تنظیمات بهبودهای خودکار را نشان میدهد،
و همه بهبودهای خودکار دردسترس را برای حساب Merchant Center فعال میکند.
update_mask روی * تنظیم شده است، یعنی همه فیلدهای ارائهشده در شیء automatic_improvements در بدنه درخواست اعمال میشوند. پاسخ
تنظیمات بهروزشده را با مقادیر پیکربندیشده و مؤثر نشان میدهد.
جاوا
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.AutomaticImageImprovements;
import com.google.shopping.merchant.accounts.v1.AutomaticImageImprovements.ImageImprovementsAccountLevelSettings;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovements;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovementsName;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovementsServiceClient;
import com.google.shopping.merchant.accounts.v1.AutomaticImprovementsServiceSettings;
import com.google.shopping.merchant.accounts.v1.AutomaticItemUpdates;
import com.google.shopping.merchant.accounts.v1.AutomaticItemUpdates.ItemUpdatesAccountLevelSettings;
import com.google.shopping.merchant.accounts.v1.AutomaticShippingImprovements;
import com.google.shopping.merchant.accounts.v1.UpdateAutomaticImprovementsRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to update AutomaticImprovements to be enabled. */
public class UpdateAutomaticImprovementsSample {
public static void updateAutomaticImprovements(Config config) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
AutomaticImprovementsServiceSettings automaticImprovementsServiceSettings =
AutomaticImprovementsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
// Creates AutomaticImprovements name to identify AutomaticImprovements.
String name =
AutomaticImprovementsName.newBuilder()
.setAccount(config.getAccountId().toString())
.build()
.toString();
// Create AutomaticImprovements with the updated fields.
AutomaticImprovements automaticImprovements =
AutomaticImprovements.newBuilder()
.setName(name)
.setItemUpdates(
AutomaticItemUpdates.newBuilder()
.setAccountItemUpdatesSettings(
ItemUpdatesAccountLevelSettings.newBuilder()
.setAllowPriceUpdates(true)
.setAllowAvailabilityUpdates(true)
.setAllowStrictAvailabilityUpdates(true)
.setAllowConditionUpdates(true)
.build())
.build())
.setImageImprovements(
AutomaticImageImprovements.newBuilder()
.setAccountImageImprovementsSettings(
ImageImprovementsAccountLevelSettings.newBuilder()
.setAllowAutomaticImageImprovements(true)
.build())
.build())
.setShippingImprovements(
AutomaticShippingImprovements.newBuilder()
.setAllowShippingImprovements(true)
.build())
.build();
FieldMask fieldMask = FieldMask.newBuilder().addPaths("*").build();
try (AutomaticImprovementsServiceClient automaticImprovementsServiceClient =
AutomaticImprovementsServiceClient.create(automaticImprovementsServiceSettings)) {
UpdateAutomaticImprovementsRequest request =
UpdateAutomaticImprovementsRequest.newBuilder()
.setAutomaticImprovements(automaticImprovements)
.setUpdateMask(fieldMask)
.build();
System.out.println("Sending Update AutomaticImprovements request");
AutomaticImprovements response =
automaticImprovementsServiceClient.updateAutomaticImprovements(request);
System.out.println("Updated AutomaticImprovements Name below");
System.out.println(response.getName());
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
updateAutomaticImprovements(config);
}
}
PHP
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
use Google\Shopping\Merchant\Accounts\V1\AutomaticImageImprovements;
use Google\Shopping\Merchant\Accounts\V1\AutomaticImageImprovements\ImageImprovementsAccountLevelSettings;
use Google\Shopping\Merchant\Accounts\V1\AutomaticImprovements;
use Google\Shopping\Merchant\Accounts\V1\Client\AutomaticImprovementsServiceClient;
use Google\Shopping\Merchant\Accounts\V1\AutomaticItemUpdates;
use Google\Shopping\Merchant\Accounts\V1\AutomaticItemUpdates\ItemUpdatesAccountLevelSettings;
use Google\Shopping\Merchant\Accounts\V1\AutomaticShippingImprovements;
use Google\Shopping\Merchant\Accounts\V1\UpdateAutomaticImprovementsRequest;
/**
* This class demonstrates how to update AutomaticImprovements to be enabled.
*/
class UpdateAutomaticImprovementsSample
{
/**
* Helper function to construct the resource name for AutomaticImprovements.
*
* @param string $accountId The Merchant Center account ID.
* @return string The resource name in the format: accounts/{account}/automaticImprovements
*/
private static function getAutomaticImprovementsName(string $accountId): string
{
return sprintf("accounts/%s/automaticImprovements", $accountId);
}
/**
* Updates the automatic improvements settings for a Merchant Center account.
* This sample enables all automatic improvements.
*
* @param array $config The configuration array containing the account ID.
* @return void
*/
public static function updateAutomaticImprovementsSample(array $config): void
{
// Obtains OAuth credentials for authentication.
$credentials = Authentication::useServiceAccountOrTokenFile();
// Contructs an options array for the client.
$options = ['credentials' => $credentials];
// Creates a new AutomaticImprovementsServiceClient.
$automaticImprovementsServiceClient = new AutomaticImprovementsServiceClient($options);
// Constructs the full resource name for the automatic improvements settings.
$name = self::getAutomaticImprovementsName($config['accountId']);
// Prepares the AutomaticImprovements object with all settings enabled.
$automaticImprovements = new AutomaticImprovements([
'name' => $name,
'item_updates' => new AutomaticItemUpdates([
'account_item_updates_settings' => new ItemUpdatesAccountLevelSettings([
'allow_price_updates' => true,
'allow_availability_updates' => true,
'allow_strict_availability_updates' => true,
'allow_condition_updates' => true
])
]),
'image_improvements' => new AutomaticImageImprovements([
'account_image_improvements_settings' => new ImageImprovementsAccountLevelSettings([
'allow_automatic_image_improvements' => true
])
]),
'shipping_improvements' => new AutomaticShippingImprovements([
'allow_shipping_improvements' => true
])
]);
// Creates a FieldMask to indicate that all paths provided in $automaticImprovements
// should be updated. The "*" path means to replace all updatable fields.
$fieldMask = new FieldMask(['paths' => ['*']]);
// Creates the UpdateAutomaticImprovementsRequest.
$request = new UpdateAutomaticImprovementsRequest([
'automatic_improvements' => $automaticImprovements,
'update_mask' => $fieldMask
]);
printf("Sending Update AutomaticImprovements request%s", PHP_EOL);
try {
// Makes the API call to update automatic improvements settings.
$response = $automaticImprovementsServiceClient->updateAutomaticImprovements($request);
printf("Updated AutomaticImprovements Name below%s", PHP_EOL);
printf("%s%s", $response->getName(), PHP_EOL);
} catch (ApiException $e) {
printf("ApiException was thrown: %s%s", $e->getMessage(), PHP_EOL);
}
}
/**
* Helper to execute the sample.
*
* @return void
*/
public function callSample(): void
{
$config = Config::generateConfig();
self::updateAutomaticImprovementsSample($config);
}
}
// Runs the script.
$sample = new UpdateAutomaticImprovementsSample();
$sample->callSample();
Python
"""Updates the automatic improvements settings for a Merchant Center account."""
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 AutomaticImageImprovements
from google.shopping.merchant_accounts_v1 import AutomaticImprovements
from google.shopping.merchant_accounts_v1 import AutomaticImprovementsServiceClient
from google.shopping.merchant_accounts_v1 import AutomaticItemUpdates
from google.shopping.merchant_accounts_v1 import AutomaticShippingImprovements
from google.shopping.merchant_accounts_v1 import UpdateAutomaticImprovementsRequest
# Fetches the Merchant Center account ID from the configuration.
_ACCOUNT_ID = configuration.Configuration().read_merchant_info()
# The resource name for the AutomaticImprovements settings of the account.
# Format: accounts/{account}/automaticImprovements
_AUTOMATIC_IMPROVEMENTS_RESOURCE_NAME = (
f"accounts/{_ACCOUNT_ID}/automaticImprovements"
)
def update_automatic_improvements_settings():
"""Updates automatic improvements settings for a Merchant Center account to enable all available automatic improvements.
"""
# Generates OAuth 2.0 credentials for authenticating with the API.
credentials = generate_user_credentials.main()
# Creates a client for the AutomaticImprovementsService.
client = AutomaticImprovementsServiceClient(credentials=credentials)
# Prepares the AutomaticImprovements object with all improvements enabled.
# The 'name' field specifies the AutomaticImprovements resource to update.
automatic_improvements_config = AutomaticImprovements(
name=_AUTOMATIC_IMPROVEMENTS_RESOURCE_NAME,
item_updates=AutomaticItemUpdates(
account_item_updates_settings=AutomaticItemUpdates.ItemUpdatesAccountLevelSettings(
allow_price_updates=True,
allow_availability_updates=True,
allow_strict_availability_updates=True,
allow_condition_updates=True,
)
),
image_improvements=AutomaticImageImprovements(
account_image_improvements_settings=
AutomaticImageImprovements.ImageImprovementsAccountLevelSettings(
allow_automatic_image_improvements=True
)
),
shipping_improvements=AutomaticShippingImprovements(
allow_shipping_improvements=True
),
)
# Creates a field mask to specify which fields of the
# AutomaticImprovements resource should be updated.
# Using "*" indicates that all fields provided in the
# automatic_improvements_config object should be updated.
field_mask = field_mask_pb2.FieldMask(paths=["*"])
# Creates the update request, including the configured
# AutomaticImprovements object and the field mask.
request = UpdateAutomaticImprovementsRequest(
automatic_improvements=automatic_improvements_config,
update_mask=field_mask,
)
# Sends the request to update automatic improvements and handles the response.
try:
print("Sending Update AutomaticImprovements request")
response = client.update_automatic_improvements(request=request)
print("Updated AutomaticImprovements Name below")
print(response.name)
except RuntimeError as e:
# Catches and prints any errors that occur during the API call.
print(e)
if __name__ == "__main__":
update_automatic_improvements_settings()
cURL
curl --location --request PATCH 'https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/automaticImprovements?update_mask=*' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
"name": "accounts/{ACCOUNT_ID}/automaticImprovements",
"itemUpdates": {
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": true,
"allowConditionUpdates": true
}
},
"imageImprovements": {
"accountImageImprovementsSettings": {
"allowAutomaticImageImprovements": true
}
},
"shippingImprovements": {
"accountShippingImprovementsSettings": {
"allowShippingImprovements": true
}
}
}'