স্বয়ংক্রিয় উন্নতি হল এমন কিছু বৈশিষ্ট্যের সেট যা Google কে আপনার ওয়েবসাইটের ল্যান্ডিং পৃষ্ঠার উপর ভিত্তি করে আপনার পণ্য, ছবি এবং শিপিং অনুমান স্বয়ংক্রিয়ভাবে আপডেট করতে দেয়। এই স্বয়ংক্রিয় উন্নতিগুলি সক্ষম করলে ব্যবহারকারীর অভিজ্ঞতা উন্নত হতে পারে, আপনার পণ্যগুলিতে আরও বেশি ট্র্যাফিক আসতে পারে এবং উচ্চতর রূপান্তর হার হতে পারে।
আপনি অ্যাকাউন্টস সাব-এপিআই-এর মধ্যে AutomaticImprovements রিসোর্স ব্যবহার করতে পারেন:
- আপনার Merchant Center অ্যাকাউন্টের জন্য বর্তমান স্বয়ংক্রিয় উন্নতি সেটিংস দেখুন।
- পণ্যের দাম, প্রাপ্যতা এবং অবস্থার জন্য স্বয়ংক্রিয় আপডেট সক্ষম বা অক্ষম করুন। আরও তথ্যের জন্য, স্বয়ংক্রিয় পণ্য আপডেট সম্পর্কে দেখুন।
- স্বয়ংক্রিয় ছবি সংশোধন সক্ষম বা অক্ষম করুন। আরও তথ্যের জন্য, আপনার পণ্যের ছবি উন্নত করতে মার্চেন্ট সেন্টারকে অনুমতি দিন দেখুন।
- স্বয়ংক্রিয় শিপিং অনুমানের উন্নতি সক্ষম বা অক্ষম করুন। স্বয়ংক্রিয় শিপিং অনুমান সম্পর্কে আরও তথ্যের জন্য, আমি চাই Google আমার ক্যারিয়ারের উপর ভিত্তি করে আমার শিপিং গতি গণনা করুক ।
বিশেষ বিবেচ্য বিষয়
- সেটিংসের উত্তরাধিকার :
-
itemUpdates( স্বয়ংক্রিয় আইটেম আপডেট ) এবংimageImprovements( স্বয়ংক্রিয় চিত্রের উন্নতি ) সেটিংস তাদের উন্নত অ্যাকাউন্ট থেকে সাব-অ্যাকাউন্ট দ্বারা উত্তরাধিকারসূত্রে পাওয়া যেতে পারে। সাব-অ্যাকাউন্ট-নির্দিষ্ট সেটিংস উত্তরাধিকারসূত্রে প্রাপ্ত সেটিংসকে ওভাররাইড করে। -
shippingImprovements( স্বয়ংক্রিয় শিপিং উন্নতি ) সেটিংস উত্তরাধিকারসূত্রে পাওয়া যায় না এবং উন্নত অ্যাকাউন্টগুলিতে প্রযোজ্য হয় না।
-
- মার্চেন্ট সেন্টার UI :
-
shippingImprovementsকেবলমাত্র API এর মাধ্যমে পরিচালনা করা যায়, মার্চেন্ট সেন্টার UI এর মাধ্যমে নয়।
-
- আচরণ আপডেট করুন :
-
itemUpdates,imageImprovements, অথবাshippingImprovementsএর সেটিংস আপডেট করার সময়, API নির্দিষ্ট শীর্ষ-স্তরের উপাদানের (যেমন, সম্পূর্ণitemUpdatesঅবজেক্ট) সম্পূর্ণ প্রতিস্থাপন করে। যাচাই করুন যে আপনার আপডেট অনুরোধে আপনি যে উপাদানগুলি পরিবর্তন করতে চান তার জন্য সমস্ত উপ-ক্ষেত্র অন্তর্ভুক্ত রয়েছে, যেমনupdate_maskদ্বারা নির্দিষ্ট করা হয়েছে।
-
- পূর্বশর্ত :
- স্বয়ংক্রিয় আইটেম আপডেট সক্ষম করার আগে, আপনার ওয়েবসাইটে স্ট্রাকচার্ড ডেটা সেট আপ করা আছে কিনা তা যাচাই করুন।
স্বয়ংক্রিয় উন্নতি সেটিংস পুনরুদ্ধার করুন
আপনার Merchant Center অ্যাকাউন্টের জন্য বর্তমান স্বয়ংক্রিয় উন্নতি সেটিংস পুনরুদ্ধার করুন। এর মধ্যে আইটেম আপডেট (মূল্য, প্রাপ্যতা, অবস্থা), ছবির উন্নতি এবং শিপিং উন্নতির সেটিংস অন্তর্ভুক্ত রয়েছে। প্রতিক্রিয়াটি অ্যাকাউন্টে সরাসরি কনফিগার করা সেটিংস (যদি থাকে) এবং কার্যকর সেটিংস উভয়ই দেখায়, যা আইটেম এবং ছবির আপডেটের জন্য একটি উন্নত অ্যাকাউন্ট থেকে উত্তরাধিকার বিবেচনা করে।
GET https://merchantapi.googleapis.com/accounts/v1/accounts/<var>ACCOUNT_ID</var>/automaticImprovements
একটি সফল অনুরোধ প্রতিক্রিয়ার অংশে একটি AutomaticImprovements রিসোর্স প্রদান করে। প্রতিক্রিয়াটি সরাসরি অ্যাকাউন্টে কনফিগার করা সেটিংস এবং কার্যকর সেটিংস উভয়ই দেখায়। effective সেটিংস হল অ্যাকাউন্টে প্রয়োগ করা সেটিংস এবং স্পষ্টভাবে সেট না করা থাকলে উচ্চ-স্তরের অ্যাকাউন্ট (যেমন একটি মাল্টি-ক্লায়েন্ট অ্যাকাউন্ট) থেকে উত্তরাধিকারসূত্রে প্রাপ্ত হতে পারে।
{
"name": "accounts/12345/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);
}
}
পিএইচপি
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();
পাইথন
"""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 --location 'https://merchantapi.googleapis.com/accounts/v1/accounts/YOUR_ACCOUNT_ID/automaticImprovements' \
--header 'Authorization: Bearer <var>API_TOKEN</var>'
স্বয়ংক্রিয় উন্নতি সেটিংস আপডেট করুন
আপনার Merchant Center অ্যাকাউন্টের জন্য স্বয়ংক্রিয় উন্নতি সেটিংস পরিবর্তন করুন। itemUpdates , imageImprovements , এবং shippingImprovements এর জন্য AutomaticImprovements অবজেক্টের জন্য নির্ধারিত অবস্থা প্রদান করুন। আপনি কোন ক্ষেত্রগুলি আপডেট করছেন তা নির্দিষ্ট করতে update_mask কোয়েরি প্যারামিটার ব্যবহার করুন (উদাহরণস্বরূপ, সমস্ত প্রদত্ত সেটিংস আপডেট করতে, update_mask=* ব্যবহার করুন)।
যখন আপনি সেটিংস আপডেট করেন, তখন আপনি বিদ্যমান কনফিগারেশনটি ওভাররাইট করতে পারেন অথবা এটি সাফ করে প্যারেন্ট অ্যাকাউন্ট থেকে সেটিংস উত্তরাধিকার সূত্রে পেতে পারেন।
একটি সেটিং ওভাররাইট করতে:
update_maskএ শীর্ষ-স্তরের ক্ষেত্রের নাম (উদাহরণস্বরূপ,itemUpdatesবাimageImprovements) অন্তর্ভুক্ত করুন এবং অনুরোধের বডিতে এর নতুন কনফিগারেশন প্রদান করুন। এই ক্রিয়াটি সাব-অ্যাকাউন্টে সেই ক্ষেত্রের জন্য বিদ্যমান যেকোনো সেটিংস প্রতিস্থাপন করে।একটি সেটিং মুছে ফেলার এবং একটি প্যারেন্ট থেকে উত্তরাধিকারসূত্রে পেতে:
update_maskএ ক্ষেত্রের নামটি অন্তর্ভুক্ত করুন, কিন্তু অনুরোধের মূল অংশ থেকে সম্পূর্ণরূপে ক্ষেত্রটি বাদ দিন। এটি সাব-অ্যাকাউন্ট থেকে নির্দিষ্ট কনফিগারেশনটি সরিয়ে দেয়, যার ফলে এটি তার প্যারেন্ট থেকে সেটিংটি উত্তরাধিকারসূত্রে পায়। যদি প্যারেন্ট অ্যাকাউন্টেও কোনও সেটিং কনফিগার করা না থাকে, তাহলে সিস্টেম ডিফল্ট প্রযোজ্য হবে।
নিচের উদাহরণটি দেখায় কিভাবে একটি সাব-অ্যাকাউন্টের জন্য imageImprovements সেটিংস মুছে ফেলা যায়, যার ফলে এটি তার প্যারেন্ট অ্যাকাউন্ট থেকে সেগুলি উত্তরাধিকারসূত্রে পায়, একই সাথে itemUpdates সেটিংস আপডেট করে।
PATCH https://merchantapi.googleapis.com/accounts/v1/accounts/{account}/automaticImprovements?update_mask=itemUpdates,imageImprovements
অনুরোধের মূল অংশ ( imageImprovements বাদ দেওয়া হচ্ছেউন্নতি):
{
"name": "accounts/12345/automaticImprovements",
"itemUpdates": {
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": true,
"allowConditionUpdates": true
}
}
}
PATCH https://merchantapi.googleapis.com/accounts/v1/accounts/<var>ACCOUNT_ID</var>/automaticImprovements?update_mask=itemUpdates,imageImprovements,shippingImprovements
অনুরোধের মূল উদাহরণ (সমস্ত উন্নতি সক্ষম করে):
{
"name": "accounts/<var>ACCOUNT_ID</var>/automaticImprovements",
"itemUpdates": {
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": true,
"allowConditionUpdates": true
}
},
"imageImprovements": {
"accountImageImprovementsSettings": {
"allowAutomaticImageImprovements": true
}
},
"shippingImprovements": {
"allowShippingImprovements": true
}
}
একটি সফল অনুরোধ প্রতিক্রিয়া বডিতে আপডেট করা AutomaticImprovements রিসোর্স ফেরত পাঠায়।
{
"name": "accounts/12345/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);
}
}
পিএইচপি
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
use Google\Shopping\Merchant\Accounts\V1beta\AutomaticImageImprovements;
use Google\Shopping\Merchant\Accounts\V1beta\AutomaticImageImprovements\ImageImprovementsAccountLevelSettings;
use Google\Shopping\Merchant\Accounts\V1beta\AutomaticImprovements;
use Google\Shopping\Merchant\Accounts\V1beta\Client\AutomaticImprovementsServiceClient;
use Google\Shopping\Merchant\Accounts\V1beta\AutomaticItemUpdates;
use Google\Shopping\Merchant\Accounts\V1beta\AutomaticItemUpdates\ItemUpdatesAccountLevelSettings;
use Google\Shopping\Merchant\Accounts\V1beta\AutomaticShippingImprovements;
use Google\Shopping\Merchant\Accounts\V1beta\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();
পাইথন
"""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 --location --request PATCH 'https://merchantapi.googleapis.com/accounts/v1/accounts/YOUR_ACCOUNT_ID/automaticImprovements?update_mask=*' \
--header 'Authorization: Bearer <var>API_TOKEN</var>' \
--header 'Content-Type: application/json' \
--data '{
"name": "accounts/YOUR_ACCOUNT_ID/automaticImprovements",
"itemUpdates": {
"accountItemUpdatesSettings": {
"allowPriceUpdates": true,
"allowAvailabilityUpdates": true,
"allowStrictAvailabilityUpdates": true,
"allowConditionUpdates": true
}
},
"imageImprovements": {
"accountImageImprovementsSettings": {
"allowAutomaticImageImprovements": true
}
},
"shippingImprovements": {
"accountShippingImprovementsSettings": {
"allowShippingImprovements": true
}
}
}'