기본 데이터 소스에 보조 데이터 소스 추가
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
기본 데이터 소스에 보조 데이터 소스를 추가하는 Merchant API 코드 샘플
자바
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shopping.merchant.samples.productsdatasourcesworkflow.v1;
import shopping.merchant.samples.datasources.v1.UpdateDataSourceSample;
import shopping.merchant.samples.utils.Config;
/**
* This class demonstrates how to add supplemental DataSources to the primary DataSource's default
* rule.
*/
public class AddSupplementalDataSourceToPrimaryDataSourceSample {
public static void addSupplementalDataSourceToPrimaryDataSource(
Config config,
String primaryDataSourceName,
String firstSupplementalDataSourceName,
String secondSupplementalDataSourceName)
throws Exception {
// Update the primary DataSource's default rule to include both supplemental feeds.
UpdateDataSourceSample updateDatasource = new UpdateDataSourceSample();
updateDatasource.updateDataSource(
config,
primaryDataSourceName,
firstSupplementalDataSourceName,
secondSupplementalDataSourceName);
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
// The names of the primary and supplemental datasources.
String primaryDataSourceName = "accounts/{account_id}/dataSources/{datasource_id}";
String firstSupplementalDataSourceName = "accounts/{account_id}/dataSources/{datasource_id}";
String secondSupplementalDataSourceName = "accounts/{account_id}/dataSources/{datasource_id}";
addSupplementalDataSourceToPrimaryDataSource(
config,
primaryDataSourceName,
firstSupplementalDataSourceName,
secondSupplementalDataSourceName);
}
}
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-21(UTC)
[null,null,["최종 업데이트: 2025-08-21(UTC)"],[[["\u003cp\u003eThis Java code sample demonstrates how to add supplemental DataSources to a primary DataSource's default rule within the Google Merchant API.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eaddSupplementalDataSourceToPrimaryDataSource\u003c/code\u003e method updates the primary DataSource by incorporating specified supplemental feeds.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eUpdateDataSourceSample\u003c/code\u003e class is used to facilitate the update process of a given primary DataSource.\u003c/p\u003e\n"],["\u003cp\u003eThe main method showcases the configuration and invocation of the \u003ccode\u003eaddSupplementalDataSourceToPrimaryDataSource\u003c/code\u003e method with placeholders for account and datasource IDs.\u003c/p\u003e\n"],["\u003cp\u003eThe code is under the Apache License 2.0.\u003c/p\u003e\n"]]],["This Java code sample demonstrates adding supplemental DataSources to a primary DataSource's default rule. It utilizes the `UpdateDataSourceSample` class to update the primary DataSource. The `addSupplementalDataSourceToPrimaryDataSource` method takes configuration, the primary DataSource name, and two supplemental DataSource names as parameters. This method then updates the primary DataSource's rule. The `main` method sets up the configuration and specifies placeholder names for the primary and supplemental DataSources before invoking the primary method.\n"],null,["# Add supplemental data source to primary data source\n\nMerchant API code sample to add a supplemental data source to a primary data\nsource. \n\n### Java\n\n // Copyright 2024 Google LLC\n //\n // Licensed under the Apache License, Version 2.0 (the \"License\");\n // you may not use this file except in compliance with the License.\n // You may obtain a copy of the License at\n //\n // https://www.apache.org/licenses/LICENSE-2.0\n //\n // Unless required by applicable law or agreed to in writing, software\n // distributed under the License is distributed on an \"AS IS\" BASIS,\n // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n // See the License for the specific language governing permissions and\n // limitations under the License.\n\n package shopping.merchant.samples.productsdatasourcesworkflow.v1;\n import shopping.merchant.samples.datasources.v1.UpdateDataSourceSample;\n import shopping.merchant.samples.utils.Config;\n\n /**\n * This class demonstrates how to add supplemental DataSources to the primary DataSource's default\n * rule.\n */\n public class AddSupplementalDataSourceToPrimaryDataSourceSample {\n\n public static void addSupplementalDataSourceToPrimaryDataSource(\n Config config,\n String primaryDataSourceName,\n String firstSupplementalDataSourceName,\n String secondSupplementalDataSourceName)\n throws Exception {\n\n // Update the primary DataSource's default rule to include both supplemental feeds.\n UpdateDataSourceSample updateDatasource = new UpdateDataSourceSample();\n updateDatasource.updateDataSource(\n config,\n primaryDataSourceName,\n firstSupplementalDataSourceName,\n secondSupplementalDataSourceName);\n }\n\n public static void main(String[] args) throws Exception {\n Config config = Config.load();\n // The names of the primary and supplemental datasources.\n String primaryDataSourceName = \"accounts/{account_id}/dataSources/{datasource_id}\";\n String firstSupplementalDataSourceName = \"accounts/{account_id}/dataSources/{datasource_id}\";\n String secondSupplementalDataSourceName = \"accounts/{account_id}/dataSources/{datasource_id}\";\n\n addSupplementalDataSourceToPrimaryDataSource(\n config,\n primaryDataSourceName,\n firstSupplementalDataSourceName,\n secondSupplementalDataSourceName);\n }\n } \n https://github.com/google/merchant-api-samples/blob/c6de994268c785ce22af0065932518a9ac5b3c03/java/src/main/java/shopping/merchant/samples/productsdatasourcesworkflow/v1/AddSupplementalDataSourceToPrimaryDataSourceSample.java"]]