মার্চেন্ট ডেটা সোর্স API এর ওভারভিউ

স্বয়ংক্রিয় ডেটা উত্সগুলি Google-এ আপনার পণ্য ডেটা পাঠানো সহজ করে তোলে৷ এই ডেটা উত্সগুলি নিশ্চিত করে যে আপনার ওয়েবসাইট থেকে প্রাসঙ্গিক পণ্য সম্পর্কে সর্বাধিক আপ-টু-ডেট তথ্য Google-এর কাছে পৌঁছেছে।

এই পৃষ্ঠাটি দেখায় কিভাবে প্রোগ্রাম্যাটিকভাবে আপনার ডেটা উত্স তৈরি এবং আপডেট করতে হয় যা আপনাকে পণ্যগুলি সন্নিবেশ করতে দেয়।

কেনাকাটার জন্য সামগ্রী API আপনাকে প্রাথমিক ডেটা উত্স তৈরি করতে দেয়। মার্চেন্ট ডেটা সোর্স এপিআই-এর সাহায্যে আপনি নিম্নলিখিত ধরনের ডেটা সোর্সও তৈরি করতে পারেন:

কেনাকাটার জন্য সামগ্রী API শুধুমাত্র আপনাকে ফাইল ইনপুট সহ ডেটা উত্স পরিচালনা করতে দেয়৷ মার্চেন্ট API আপনাকে ফাইল এবং API ইনপুট উভয়ের মাধ্যমে ডেটা উত্সগুলি পরিচালনা করতে দেয়৷

কেনাকাটার জন্য বিষয়বস্তু API-এর সাথে এটি কীভাবে তুলনা করে সে সম্পর্কে আরও তথ্যের জন্য, ডেটা সোর্স ম্যানেজমেন্ট মাইগ্রেট দেখুন।

বণিক ডেটা উত্স API ব্যবহার করে, আপনি নিম্নলিখিতগুলি করতে পারেন:

  • একটি নির্দিষ্ট feedLabel এবং contentLanguage সহ একটি প্রাথমিক তথ্য উৎস তৈরি করুন।
  • feedLabel এবং contentLanguage ক্ষেত্রগুলি সেট করা নেই এমন একটি ডেটা উত্স তৈরি করুন৷ এই ধরনের ডেটা উত্স ব্যবহার করে আপনি আপনার পণ্যগুলির জন্য একাধিক দেশকে লক্ষ্য করতে পারেন, কারণ আপনি একটি একক ডেটা উত্সে feedLabel এবং contentLanguage এর বিভিন্ন সংমিশ্রণ সহ পণ্যগুলি সন্নিবেশ করতে পারেন৷
  • একটি বিদ্যমান প্রাথমিক ডেটা উত্সের সাথে লিঙ্ক করতে একটি সম্পূরক ডেটা উত্স তৈরি করুন৷
  • একটি ফাইল ডেটা উৎসের জন্য একটি সময়সূচী সেট আপ করুন।
  • ডেটা উত্সগুলির স্বয়ংক্রিয় পরিচালনার জন্য আপনার অ্যাকাউন্ট নথিভুক্ত করুন৷
  • API ডেটা উত্স পরিচালনা করুন।
  • প্রাথমিক পণ্য ডেটা উত্স ব্যবহার করে ডেটা উত্সগুলির ডিফল্ট নিয়ম পরিচালনা করুন৷
  • প্রচারের মত অন্যান্য ধরনের ডেটা উৎস ব্যবহার করুন।

ডেটা উত্স চ্যানেল সম্পর্কে আরও তথ্যের জন্য, চ্যানেলগুলি দেখুন৷

পূর্বশর্ত

  • আপনার অ্যাকাউন্ট অবশ্যই একক লোকেল ফিডে স্থানান্তরিত হয়েছে।
  • অ্যাকাউন্টটি ইতিমধ্যেই ডেটা টার্গেট স্প্লিটে স্থানান্তরিত হয়েছে তা যাচাই করতে, ডেটা উত্স তালিকা ব্যবহার করুন বা পদ্ধতিগুলি পান৷ যদি আপনি যোগ্য না হন, আপনি নিম্নলিখিত ব্যতিক্রম বার্তা পাবেন এবং আপনার সমর্থনে যোগাযোগ করা উচিত।

    This account is in the data sources migration process and can't be used with
    this API yet. Contact support for more info on when this account will be able
    to use the data sources endpoint.
    

একটি ডেটা উত্স তৈরি করুন

আপনার Merchant Center ইনভেনটরির জন্য প্রাথমিক ডেটা উত্সগুলি হল প্রধান ডেটা উত্স৷ আপনি শুধুমাত্র একটি প্রাথমিক ডেটা উৎস ব্যবহার করে পণ্য যোগ বা সরাতে পারেন। আপনার প্রাথমিক ডেটা উত্সে আপনি যোগ করা প্রতিটি পণ্য যদি বণিক কেন্দ্রের ডেটা এবং যোগ্যতার প্রয়োজনীয়তাগুলি পূরণ করে, তাহলে আপনাকে আর কোনও ডেটা উত্স তৈরি করতে হবে না৷

একটি নির্দিষ্ট feedLabel এবং contentLanguage সহ একটি প্রাথমিক ডেটা উৎস তৈরি করতে, টাইপ-নির্দিষ্ট কনফিগারেশনে feedLabel এবং contentLanguage ক্ষেত্রগুলি সেট করুন। এই ক্ষেত্রগুলি সম্পর্কে আরও তথ্যের জন্য, PrimaryProductDataSource দেখুন।

নিম্নলিখিত নমুনা অনুরোধটি কীভাবে একটি প্রাথমিক পণ্য ডেটা উত্স তৈরি করতে হয় তা প্রদর্শন করে:

POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/{ACCOUNT_ID}/dataSources

{
  "displayName": "{DISPLAY_NAME}",
  "primaryProductDataSource": {
    "contentLanguage": "{CONTENT_LANGUAGE}",
    "feedLabel": "{FEED_LABEL}",
    "countries": [
      "{COUNTRY}"
    ],
    "channel": "ONLINE_PRODUCTS"
  }
}

নিম্নলিখিতগুলি প্রতিস্থাপন করুন:

  • {ACCOUNT_ID} : আপনার Merchant Center অ্যাকাউন্টের অনন্য শনাক্তকারী।
  • {DISPLAY_NAME} : ডেটা উৎসের প্রদর্শন নাম।
  • {CONTENT_LANGUAGE} : ডেটা উৎসে পণ্যগুলির দুই-অক্ষরের ISO 639-1 ভাষার কোড।
  • {FEED_LABEL} : ডেটা উৎসের ফিড লেবেল।
  • {COUNTRY} : ডেটা উত্স ব্যবহার করে আপলোড করা পণ্যগুলির লক্ষ্য দেশের CLDR অঞ্চল কোড৷

অনুরোধ সফলভাবে চালানোর পরে, আপনি নিম্নলিখিত প্রতিক্রিয়া দেখতে পাবেন:

{
  "name": "accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}",
  "dataSourceId": "{DATASOURCE_ID}",
  "displayName": "{DISPLAY_NAME}",
  "primaryProductDataSource": {
    "channel": "ONLINE_PRODUCTS",
    "feedLabel": "{FEED_LABEL}",
    "contentLanguage": "{CONTENT_LANGUAGE}",
    "countries": [
      "{COUNTRY}"
    ],
    "defaultRule": {
      "takeFromDataSources": [
        {
          "self": true
        }
      ]
    }
  },
  "input": "API"
}

একটি ডেটা উৎস তৈরি সম্পর্কে আরও তথ্যের জন্য, accounts.dataSources.create পদ্ধতি দেখুন।

আপনার নতুন তৈরি করা ডেটা উৎস দেখতে, accounts.dataSources.get বা accounts.dataSources.list পদ্ধতি ব্যবহার করুন।

নিচের নমুনাটি দেখায় কিভাবে আপনি GB এবং en feedLabel এবং contentLanguage সমন্বয়ের জন্য একটি প্রাথমিক পণ্য ডেটা উৎস তৈরি করতে পারেন।

জাভা

   import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.datasources.v1beta.CreateDataSourceRequest;
import com.google.shopping.merchant.datasources.v1beta.DataSource;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/**
 * This class demonstrates how to create a primary product datasource for all `feedLabel` and
 * `contentLanguage` combinations. Note that rules functionality is limited for wildcard feeds.
 */
public class CreatePrimaryProductDataSourceWildCardSample {

  private static String getParent(String merchantId) {
    return String.format("accounts/%s", merchantId);
  }

  public static String createDataSource(Config config, String displayName) throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String parent = getParent(config.getAccountId().toString());

    // The type of data that this datasource will receive.
    PrimaryProductDataSource primaryProductDataSource =
        PrimaryProductDataSource.newBuilder()
            // Channel can be "ONLINE_PRODUCTS" or "LOCAL_PRODUCTS" or "PRODUCTS" .
            // While accepted, datasources with channel "products" representing unified products
            // currently cannot be used with the Products bundle.
            .setChannel(PrimaryProductDataSource.Channel.ONLINE_PRODUCTS)
            .addCountries("GB")
            .build();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      CreateDataSourceRequest request =
          CreateDataSourceRequest.newBuilder()
              .setParent(parent)
              .setDataSource(
                  DataSource.newBuilder()
                      .setDisplayName(displayName)
                      .setPrimaryProductDataSource(primaryProductDataSource)
                      .build())
              .build();

      System.out.println("Sending Create PrimaryProduct DataSource request");
      DataSource response = dataSourcesServiceClient.createDataSource(request);
      System.out.println("Created DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      // Null is necessary to satisfy the compiler as we're not returning a String on failure.
      return null;
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    // The displayed datasource name in the Merchant Center UI.
    String displayName = "Primary Product Data Wildcard";

    createDataSource(config, displayName);
  }
}

একটি নতুন প্রাথমিক ডেটা উত্স তৈরি করুন যা একাধিক দেশকে লক্ষ্য করতে সহায়তা করে৷

একটি নতুন প্রাথমিক ফিড তৈরি করতে যা আপনাকে একাধিক দেশকে টার্গেট করতে সহায়তা করে, PrimaryProductDataSource ব্যবহার করে আপনার ডেটা উত্স কনফিগার করুন এবং feedLabel এবং contentLanguage ক্ষেত্রগুলি সেট করবেন না৷

কেনাকাটার জন্য সামগ্রী API ব্যবহার করে, আপনার জন্য শুধুমাত্র একটি API ডেটা উৎস তৈরি করা হয়েছে। মার্চেন্ট ডেটা সোর্স API ব্যবহার করে, আপনার একাধিক API ডেটা উত্স থাকতে পারে, যার মধ্যে কিছু feedLabel এবং contentLanguage ফিল্ড সেট ছাড়াই হতে পারে।

শুধুমাত্র API ইনপুট সহ ডেটা উত্সগুলি feedLabel এবং contentLanguage ফিল্ড সেট ছাড়াই থাকতে পারে৷ এই ধরনের ডেটা উত্স ফাইল ইনপুটগুলির জন্য সমর্থিত নয়৷

একটি সম্পূরক তথ্য উৎস তৈরি করুন এবং প্রাথমিক তথ্য উৎসের সাথে লিঙ্ক করুন

পরিপূরক ডেটা উত্সগুলি শুধুমাত্র এমন পণ্য ডেটা আপডেট করতে ব্যবহার করা হয় যা ইতিমধ্যে এক বা একাধিক প্রাথমিক ডেটা উত্সে বিদ্যমান। আপনার একাধিক পরিপূরক ডেটা উত্স থাকতে পারে এবং প্রত্যেকটি প্রাথমিক ডেটা উত্সের যেকোনো সংখ্যক ডেটার পরিপূরক করতে পারে।

আপনি accounts.productInputs.insert এবং accounts.productInputs.delete পদ্ধতিতে কল করার সময় একটি ক্যোয়ারী প্যারামিটার হিসাবে ডেটা উৎসের অনন্য শনাক্তকারী যোগ করে পণ্য ডেটাতে আংশিক আপডেট করতে সম্পূরক ডেটা উত্স ব্যবহার করতে পারেন৷ আপনি বিদ্যমান পণ্য আপডেট করার জন্য শুধুমাত্র সম্পূরক ডেটা উৎস ব্যবহার করতে পারেন।

একটি পরিপূরক ডেটা উৎস তৈরি করতে, SupplementalProductDataSource ব্যবহার করে আপনার ডেটা সোর্স কনফিগার করুন এবং তারপর আপনার প্রাথমিক ডেটা সোর্সের defaultRule ফিল্ড আপডেট করে লিঙ্ক করুন।

পরিপূরক ফাইল ডেটা উত্সগুলিতে অবশ্যই feedLabel এবং contentLanguage ক্ষেত্র সেট থাকতে হবে। পরিপূরক API ডেটা উত্সগুলিতে সর্বদা feedLabel এবং contentLanguage ক্ষেত্রগুলি আনসেট থাকতে হবে৷

নিচের নমুনাটি দেখায় কিভাবে আপনি en এবং GB contentLanguage এবং feedLabel সমন্বয়ের জন্য একটি ফাইল সম্পূরক পণ্য ডেটা উৎস তৈরি করতে পারেন।

জাভা

   import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.datasources.v1beta.CreateDataSourceRequest;
import com.google.shopping.merchant.datasources.v1beta.DataSource;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1beta.FileInput;
import com.google.shopping.merchant.datasources.v1beta.SupplementalProductDataSource;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/**
 * This class demonstrates how to create a File Supplemental product datasource for the "en" and
 * "GB" `feedLabel` and `contentLanguage` combination. This supplemental feed is eligible to be
 * linked to both a wildcard primary feed and/or a primary feed with the same `feedLabel` and
 * `contentLanguage` combination.
 */
public class CreateFileSupplementalProductDataSourceSample {

  private static String getParent(String merchantId) {
    return String.format("accounts/%s", merchantId);
  }

  private static FileInput setFileInput() {
    // If FetchSettings are not set, then this will be an `UPLOAD` file type
    // that you must manually upload via the Merchant Center UI.
    return FileInput.newBuilder()
        // FileName is required for `UPLOAD` fileInput type.
        .setFileName("British T-shirts Supplemental Data")
        .build();
  }

  public static String createDataSource(Config config, String displayName, FileInput fileInput)
      throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String parent = getParent(config.getAccountId().toString());

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      CreateDataSourceRequest request =
          CreateDataSourceRequest.newBuilder()
              .setParent(parent)
              .setDataSource(
                  DataSource.newBuilder()
                      .setDisplayName(displayName)
                      .setSupplementalProductDataSource(
                          SupplementalProductDataSource.newBuilder()
                              .setContentLanguage("en")
                              .setFeedLabel("GB")
                              .build())
                      .setFileInput(fileInput)
                      .build())
              .build();

      System.out.println("Sending create SupplementalProduct DataSource request");
      DataSource response = dataSourcesServiceClient.createDataSource(request);
      System.out.println("Created DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      // Null is necessary to satisfy the compiler as we're not returning a String on failure.
      return null;
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    // The displayed datasource name in the Merchant Center UI.
    String displayName = "British File Supplemental Product Data";

    // The file input data that this datasource will receive.
    FileInput fileInput = setFileInput();

    createDataSource(config, displayName, fileInput);
  }
}

একটি সম্পূরক ডেটা উৎস তৈরি করতে যা সমস্ত feedLabel এবং contentLanguage সমন্বয়ের জন্য কাজ করে, নিম্নলিখিত নমুনাটি চালান।

জাভা

   import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.datasources.v1beta.CreateDataSourceRequest;
import com.google.shopping.merchant.datasources.v1beta.DataSource;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1beta.SupplementalProductDataSource;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/**
 * This class demonstrates how to create a Supplemental product datasource all `feedLabel` and
 * `contentLanguage` combinations. This works only for API supplemental feeds.
 */
public class CreateSupplementalProductDataSourceWildCardSample {

  private static String getParent(String merchantId) {
    return String.format("accounts/%s", merchantId);
  }

  public static String createDataSource(Config config, String displayName) throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String parent = getParent(config.getAccountId().toString());

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      CreateDataSourceRequest request =
          CreateDataSourceRequest.newBuilder()
              .setParent(parent)
              .setDataSource(
                  DataSource.newBuilder()
                      .setDisplayName(displayName)
                      .setSupplementalProductDataSource(
                          SupplementalProductDataSource.newBuilder().build())
                      .build())
              .build();

      System.out.println("Sending create SupplementalProduct DataSource request");
      DataSource response = dataSourcesServiceClient.createDataSource(request);
      System.out.println("Created DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null; // Necessary to satisfy the compiler as we're not returning a
      // String on failure.
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    // The displayed datasource name in the Merchant Center UI.
    String displayName = "Supplemental API Product Data Wildcard";

    createDataSource(config, displayName);
  }
}

আপনার ফাইল ডেটা উৎসের জন্য একটি সময়সূচী সেট আপ করুন

আপনার ফাইল ফিডের জন্য একটি সময়সূচী সেট আপ করতে, FileInput ক্ষেত্রটি ব্যবহার করে আপনার ডেটা উত্সটিকে একটি ফাইল ডেটা উত্স হিসাবে কনফিগার করুন এবং তারপর FileInput.FetchSettings ক্ষেত্র ব্যবহার করে fetchsettings সেট আপ করুন৷

একটি ডেটা উৎস মুছুন

আপনার অ্যাকাউন্ট থেকে একটি বিদ্যমান ডেটা উৎস মুছে ফেলতে, accounts.dataSources.delete পদ্ধতি ব্যবহার করুন।

নিম্নলিখিত নমুনা প্রদর্শন করে যে আপনি কীভাবে একটি ডেটা উত্স মুছতে DeleteDataSourceRequest প্যাকেজ ব্যবহার করতে পারেন।

জাভা

   import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.datasources.v1beta.DataSourceName;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1beta.DeleteDataSourceRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to delete a datasource. */
public class DeleteDataSourceSample {

  public static void deleteDataSource(Config config, String dataSourceId) throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String name =
        DataSourceName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .setDatasource(dataSourceId)
            .build()
            .toString();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {
      DeleteDataSourceRequest request = DeleteDataSourceRequest.newBuilder().setName(name).build();

      System.out.println("Sending deleteDataSource request");
      // Delete works for any datasource type.
      // If Type "Supplemental", delete will only work if it's not linked to any primary feed.
      // If a link exists and the Type is "Supplemental", you will need to remove the supplemental
      // feed from the default and/or custom rule(s) of any primary feed(s) that references it. Then
      // retry the delete.

      dataSourcesServiceClient.deleteDataSource(request); // No response returned on success.
      System.out.println(
          "Delete successful, note that it may take a few minutes for the delete to update in"
              + " the system.");
    } catch (Exception e) {
      System.out.println(e);
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    // An ID automatically assigned to the datasource after creation by Google.
    String dataSourceId = "1111111111"; // Replace with your datasource ID.

    deleteDataSource(config, dataSourceId);
  }
}

তথ্য উৎস আনুন

ডেটা উৎসে কনফিগার করা একটি ফাইল আনতে, accounts.dataSources.fetch পদ্ধতি ব্যবহার করুন। এই পদ্ধতিটি আপনার অ্যাকাউন্ট থেকে ডেটা উৎসে অবিলম্বে ডেটা আনয়ন সম্পাদন করে। এই পদ্ধতিটি শুধুমাত্র একটি ফাইল ইনপুট সেট সহ ডেটা উত্সগুলিতে কাজ করে।

ডাটা সোর্স পান

আপনার অ্যাকাউন্টের জন্য ডেটা উৎস কনফিগারেশন পুনরুদ্ধার করতে, accounts.dataSources.get পদ্ধতি ব্যবহার করুন।

নিম্নলিখিত নমুনাটি দেখায় যে আপনি কীভাবে একটি প্রদত্ত বণিক কেন্দ্র অ্যাকাউন্টের জন্য একটি নির্দিষ্ট ডেটা উত্স পুনরুদ্ধার করতে GetDataSourceRequest প্যাকেজ ব্যবহার করতে পারেন৷

জাভা

   import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.datasources.v1beta.DataSource;
import com.google.shopping.merchant.datasources.v1beta.DataSourceName;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1beta.GetDataSourceRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to get a specific datasource for a given Merchant Center account. */
public class GetDataSourceSample {

  public static DataSource getDataSource(Config config, String dataSourceId) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates datasource name to identify datasource.
    String name =
        DataSourceName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .setDatasource(dataSourceId)
            .build()
            .toString();

    // Calls the API and catches and prints any network failures/errors.
    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      // The name has the format: accounts/{account}/datasources/{datasource}
      GetDataSourceRequest request = GetDataSourceRequest.newBuilder().setName(name).build();

      System.out.println("Sending GET DataSource request:");
      DataSource response = dataSourcesServiceClient.getDataSource(request);

      System.out.println("Retrieved DataSource below");
      System.out.println(response);
      return response;
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null; // Necessary to satisfy the compiler as we're not returning a
      // DataSource on failure.
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    // An ID assigned to a datasource by Google.
    String datasourceId = "1111111111"; // Replace with your datasource ID.

    getDataSource(config, datasourceId);
  }
}

তথ্য উৎস তালিকা

আপনার অ্যাকাউন্টের জন্য ডেটা উত্সগুলির জন্য কনফিগারেশনগুলি তালিকাভুক্ত করতে, accounts.dataSources.list পদ্ধতি ব্যবহার করুন৷

নিম্নলিখিত নমুনা দেখায় যে আপনি কীভাবে একটি প্রদত্ত বণিক কেন্দ্র অ্যাকাউন্টের সমস্ত ডেটা উত্স তালিকাভুক্ত করতে ListDataSourceRequest প্যাকেজ ব্যবহার করতে পারেন৷

জাভা

   import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.datasources.v1beta.DataSource;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient.ListDataSourcesPagedResponse;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1beta.ListDataSourcesRequest;
import java.util.ArrayList;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/** This class demonstrates how to list all the datasources for a given Merchant Center account */
public class ListDataSourcesSample {

  private static String getParent(String accountId) {
    return String.format("accounts/%s", accountId);
  }

  public static ArrayList<DataSource> listDataSources(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.
    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates parent to identify the account from which to list all the datasources.
    String parent = getParent(config.getAccountId().toString());

    // Calls the API and catches and prints any network failures/errors.
    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      // The parent has the format: accounts/{account}
      ListDataSourcesRequest request =
          ListDataSourcesRequest.newBuilder().setParent(parent).build();

      System.out.println("Sending list datasources request:");
      ListDataSourcesPagedResponse response = dataSourcesServiceClient.listDataSources(request);

      int count = 0;
      ArrayList<DataSource> dataSources = new ArrayList<DataSource>();
      ArrayList<DataSource> justPrimaryDataSources = new ArrayList<DataSource>();

      // Iterates over all rows in all pages and prints the datasource in each row.
      // Automatically uses the `nextPageToken` if returned to fetch all pages of data.
      for (DataSource element : response.iterateAll()) {
        System.out.println(element);
        count++;
        dataSources.add(element);
        // The below lines show how to filter datasources based on type.
        // `element.hasSupplementalProductDataSource()` would give you supplemental
        // datasources, etc.
        if (element.hasPrimaryProductDataSource()) {
          justPrimaryDataSources.add(element);
        }
      }
      System.out.print("The following count of elements were returned: ");
      System.out.println(count);
      return dataSources;
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null; // Necessary to satisfy the compiler as we're not returning an
      // ArrayList<DataSource> on failure.
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();

    listDataSources(config);
  }
}

প্যাচ ডেটা উৎস

একটি বিদ্যমান ডেটা উৎসের কনফিগারেশন আপডেট করতে, accounts.dataSources.patch পদ্ধতি ব্যবহার করুন।

নিচের নমুনাটি দেখায় কিভাবে আপনি একটি ডেটা উৎস আপডেট করতে UpdateDataSourceRequest প্যাকেজ ব্যবহার করতে পারেন। এটি ডিফল্ট নিয়মে সম্পূরক ডেটা উত্স যুক্ত করতে প্রাথমিক ডেটা উত্স কীভাবে আপডেট করতে হয় তাও এটি প্রদর্শন করে।

জাভা

   import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.protobuf.FieldMask;
import com.google.shopping.merchant.datasources.v1beta.DataSource;
import com.google.shopping.merchant.datasources.v1beta.DataSourceName;
import com.google.shopping.merchant.datasources.v1beta.DataSourceReference;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceClient;
import com.google.shopping.merchant.datasources.v1beta.DataSourcesServiceSettings;
import com.google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource;
import com.google.shopping.merchant.datasources.v1beta.PrimaryProductDataSource.DefaultRule;
import com.google.shopping.merchant.datasources.v1beta.UpdateDataSourceRequest;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;

/**
 * This class demonstrates how to update a datasource to change its name in the MC UI. It also
 * demonstrates how to update a primary datasource to add supplemental datasources to its default
 * rule (https://support.google.com/merchants/answer/7450276).
 */
public class UpdateDataSourceSample {

  public static String updateDataSource(Config config, String displayName, String dataSourceId)
      throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates datasource name to identify datasource.
    String name =
        DataSourceName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .setDatasource(dataSourceId)
            .build()
            .toString();

    DataSource dataSource =
        DataSource.newBuilder()
            // Update the datasource to have the new display name
            .setDisplayName(displayName)
            .setName(name)
            .build();

    FieldMask fieldMask = FieldMask.newBuilder().addPaths("display_name").build();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      UpdateDataSourceRequest request =
          UpdateDataSourceRequest.newBuilder()
              .setDataSource(dataSource)
              .setUpdateMask(fieldMask)
              .build();

      System.out.println("Sending Update DataSource request");
      DataSource response = dataSourcesServiceClient.updateDataSource(request);
      System.out.println("Updated DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null;
    }
  }

  public String updateDataSource(
      Config config,
      String primaryDataSourceName,
      String firstSupplementalDataSourceName,
      String secondSupplementalDataSourceName)
      throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Setting self to 'true' refers to the primary datasource itself.
    DataSourceReference dataSourceReferenceSelf =
        DataSourceReference.newBuilder().setSelf(true).build();
    DataSourceReference firstSupplementalDataSourceReference =
        DataSourceReference.newBuilder()
            .setSupplementalDataSourceName(firstSupplementalDataSourceName)
            .build();
    DataSourceReference secondSupplementalDataSourceReference =
        DataSourceReference.newBuilder()
            .setSupplementalDataSourceName(secondSupplementalDataSourceName)
            .build();

    // The attributes will first be taken from the primary DataSource.
    // Then the first supplemental DataSource if the attribute is not in the primary DataSource
    // And finally the second supplemental DataSource if not in the first two DataSources.
    // Note that CustomRules could change the behavior of how updates are applied.
    DefaultRule defaultRule =
        DefaultRule.newBuilder()
            .addTakeFromDataSources(dataSourceReferenceSelf)
            .addTakeFromDataSources(firstSupplementalDataSourceReference)
            .addTakeFromDataSources(secondSupplementalDataSourceReference)
            .build();

    // The type of data that this datasource will receive.
    PrimaryProductDataSource primaryProductDataSource =
        PrimaryProductDataSource.newBuilder().setDefaultRule(defaultRule).build();

    DataSource dataSource =
        DataSource.newBuilder()
            // Update the primary datasource to have the default rule datasources in the correct
            // order.
            .setPrimaryProductDataSource(primaryProductDataSource)
            .setName(primaryDataSourceName)
            .build();

    // The '.' signifies a nested field.
    FieldMask fieldMask =
        FieldMask.newBuilder().addPaths("primary_product_data_source.default_rule").build();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      UpdateDataSourceRequest request =
          UpdateDataSourceRequest.newBuilder()
              .setDataSource(dataSource)
              .setUpdateMask(fieldMask)
              .build();

      System.out.println("Sending Update DataSource request");
      DataSource response = dataSourcesServiceClient.updateDataSource(request);
      System.out.println("Updated DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null;
    }
  }

  public static void main(String[] args) throws Exception {
    Config config = Config.load();
    // The updated displayed datasource name in the Merchant Center UI.
    String displayName = "Great Britain Primary Product Data";

    // The ID of the datasource to update
    String dataSourceId = "11111111"; // Replace with your datasource ID.

    updateDataSource(config, displayName, dataSourceId);
  }
}

প্রাথমিক পণ্য ডেটা উত্সগুলি আপনাকে ডেটা উত্সগুলির ডিফল্ট নিয়ম পরিচালনা করতে দেয়৷ ডিফল্ট নিয়ম হল সেই নিয়ম যা আপনার ডেটা উৎসের সমস্ত বৈশিষ্ট্যের ক্ষেত্রে প্রযোজ্য। ডেটা উত্স তৈরি করার সময় বা ডিফল্ট নিয়ম ক্ষেত্রের মাধ্যমে একটি বিদ্যমান ডেটা উত্স আপডেট করার সময় ডিফল্ট নিয়ম সেট করা যেতে পারে।

নিয়ম সেট আপ সম্পর্কে আরও তথ্যের জন্য, আপনার পণ্য ডেটা উত্সগুলির জন্য নিয়ম সেট আপ দেখুন৷

নিম্নলিখিত নমুনা কনফিগারেশন নিশ্চিত করে যে সমস্ত বৈশিষ্ট্যগুলি প্রথমে অনন্য শনাক্তকারী 1001 সহ ডেটা উত্স থেকে নেওয়া হয়েছে৷ তারপরে অনুপস্থিত বৈশিষ্ট্যগুলি প্রাথমিক ডেটা উত্স থেকে যোগ করা হয়। অবশেষে, অবশিষ্ট বৈশিষ্ট্যগুলি সম্পূরক ডেটা উত্স থেকে অনন্য শনাক্তকারী 1002 সহ নেওয়া হবে যদি ইতিমধ্যে অন্য কোনও ডেটা উত্সে সরবরাহ করা না থাকে৷ একই বৈশিষ্ট্য একাধিক ডেটা উৎসে প্রদান করা হলে, তালিকার উচ্চতর মান নির্বাচন করা হয়।

defaultRule {
 takeFromDataSources: [
   '1001', // Supplemental product data source
   'self', //  Self reference to the primary data source
   '1002' // Supplemental product data source
 ]
}

ফিডের স্বয়ংক্রিয় ব্যবস্থাপনা

ডেটা উত্সগুলির স্বয়ংক্রিয় পরিচালনার জন্য আপনার অ্যাকাউন্ট নথিভুক্ত করতে, আপনাকে অবশ্যই নিম্নলিখিতগুলি করতে হবে:

আপনার অ্যাকাউন্ট তালিকাভুক্তির জন্য যোগ্য হওয়ার পরে, আপনি ডেটা উত্সগুলির স্বয়ংক্রিয় ব্যবস্থাপনা সক্ষম করতে accounts.autofeedSettings.updateAutofeedSettings পদ্ধতি ব্যবহার করতে পারেন৷ ডেটা উত্সগুলির স্বয়ংক্রিয় ব্যবস্থাপনা সক্ষম করা Google কে স্বয়ংক্রিয়ভাবে আপনার অনলাইন স্টোর থেকে আপনার পণ্যগুলিকে যুক্ত করতে দেয় এবং নিশ্চিত করে যে সেগুলি সর্বদা Google এর প্ল্যাটফর্মে আপ টু ডেট থাকে৷

ফাইল আপলোড স্থিতি পুনরুদ্ধার করুন

ফাইল, আনয়ন বা স্প্রেডশীট সহ একটি ডেটা উত্সের স্থিতি পেতে, আপনি accounts.dataSources.fileUploads পরিষেবার GET পদ্ধতিতে কল করতে পারেন৷ ডেটা উত্স প্রক্রিয়াকরণ শেষ হলে অ্যাসিঙ্ক্রোনাসভাবে গণনা করা ডেটা উত্সের শেষ পুনরুদ্ধারের ফলাফল পেতে, নাম শনাক্তকারী latest ব্যবহার করুন৷

GET https://merchantapi.googleapis.com/accounts/v1beta/{ACCOUNT_ID}/datasources/{DATASOURCE_ID}/fileUploads/latest

ফাইল আপলোড স্থিতিতে আপনার পণ্যগুলির একটি বিশদ দৃশ্য থাকতে পারে, যেকোন সম্ভাব্য সমস্যা সহ।

মনে রাখবেন যে ফাইলটি আপলোড না হলে ফাইল আপলোডের স্থিতি বিদ্যমান নাও থাকতে পারে। ফাইল আপলোড করার শীঘ্রই অনুরোধ করা হলে ফাইল আপলোডের স্থিতি প্রক্রিয়াকরণ অবস্থায় থাকতে পারে।