แสดงปัญหาเกี่ยวกับผลิตภัณฑ์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ตัวอย่างโค้ด Merchant API เพื่อแสดงปัญหาเกี่ยวกับผลิตภัณฑ์
Java
// Copyright 2025 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.issueresolution.v1;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.issueresolution.v1.IssueResolutionServiceClient;
import com.google.shopping.merchant.issueresolution.v1.IssueResolutionServiceSettings;
import com.google.shopping.merchant.issueresolution.v1.ProductName;
import com.google.shopping.merchant.issueresolution.v1.RenderIssuesRequestPayload;
import com.google.shopping.merchant.issueresolution.v1.RenderProductIssuesRequest;
import com.google.shopping.merchant.issueresolution.v1.RenderProductIssuesResponse;
import com.google.shopping.merchant.issueresolution.v1.RenderedIssue;
import com.google.shopping.merchant.issueresolution.v1.UserInputActionRenderingOption;
import java.io.IOException;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to render product issues for a given Merchant Center account */
public class RenderProductIssuesSample {
private static void renderProductIssuesSample(
Config config,
String productId,
String languageCode,
String timeZone,
UserInputActionRenderingOption userInputActionOption)
throws IOException {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
IssueResolutionServiceSettings settings =
IssueResolutionServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String accountId = config.getAccountId().toString();
String name =
ProductName.newBuilder().setAccount(accountId).setProduct(productId).build().toString();
try (IssueResolutionServiceClient client = IssueResolutionServiceClient.create(settings)) {
RenderProductIssuesRequest request =
RenderProductIssuesRequest.newBuilder()
.setName(name)
.setLanguageCode(languageCode)
.setTimeZone(timeZone)
.setPayload(
RenderIssuesRequestPayload.newBuilder()
.setUserInputActionOption(userInputActionOption)
.build())
.build();
System.out.println("Sending RenderProductIssues request");
RenderProductIssuesResponse response = client.renderProductIssues(request);
System.out.println("The full response:");
System.out.println(response);
System.out.println("-----------------------------------------------------------------");
System.out.println(
"Summary: " + response.getRenderedIssuesCount() + " issues found for the product");
System.out.println("-----------------------------------------------------------------");
for (RenderedIssue issue : response.getRenderedIssuesList()) {
System.out.println(); // empty line for formatting
SimpleRenderer.printIssue(issue);
}
} 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();
String timeZone = "Europe/Zurich";
String languageCode = "en_GB";
// The simple option: request all complex actions to be handled as redirects to
// the Merchant Center. e.g. send the merchant to MC to request an appeal.
UserInputActionRenderingOption inputActionOption =
UserInputActionRenderingOption.REDIRECT_TO_MERCHANT_CENTER;
// An ID assigned to a product by Google. In the format
// channel~contentLanguage~feedLabel~offerId
String productId = "online~en~label~sku123";
renderProductIssuesSample(config, productId, languageCode, timeZone, inputActionOption);
}
}
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-21 UTC
[null,null,["อัปเดตล่าสุด 2025-08-21 UTC"],[],[],null,["# Render product issues\n\nMerchant API code sample to render product issues. \n\n### Java\n\n // Copyright 2025 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 package shopping.merchant.samples.issueresolution.v1;\n\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.merchant.issueresolution.v1.IssueResolutionServiceClient;\n import com.google.shopping.merchant.issueresolution.v1.IssueResolutionServiceSettings;\n import com.google.shopping.merchant.issueresolution.v1.ProductName;\n import com.google.shopping.merchant.issueresolution.v1.RenderIssuesRequestPayload;\n import com.google.shopping.merchant.issueresolution.v1.RenderProductIssuesRequest;\n import com.google.shopping.merchant.issueresolution.v1.RenderProductIssuesResponse;\n import com.google.shopping.merchant.issueresolution.v1.RenderedIssue;\n import com.google.shopping.merchant.issueresolution.v1.UserInputActionRenderingOption;\n import java.io.IOException;\n import shopping.merchant.samples.utils.Authenticator;\n import shopping.merchant.samples.utils.Config;\n\n /** This class demonstrates how to render product issues for a given Merchant Center account */\n public class RenderProductIssuesSample {\n\n private static void renderProductIssuesSample(\n Config config,\n String productId,\n String languageCode,\n String timeZone,\n UserInputActionRenderingOption userInputActionOption)\n throws IOException {\n\n // Obtains OAuth token based on the user's configuration.\n GoogleCredentials credential = new Authenticator().authenticate();\n\n IssueResolutionServiceSettings settings =\n IssueResolutionServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n String accountId = config.getAccountId().toString();\n String name =\n ProductName.newBuilder().setAccount(accountId).setProduct(productId).build().toString();\n\n try (IssueResolutionServiceClient client = IssueResolutionServiceClient.create(settings)) {\n\n RenderProductIssuesRequest request =\n RenderProductIssuesRequest.newBuilder()\n .setName(name)\n .setLanguageCode(languageCode)\n .setTimeZone(timeZone)\n .setPayload(\n RenderIssuesRequestPayload.newBuilder()\n .setUserInputActionOption(userInputActionOption)\n .build())\n .build();\n\n System.out.println(\"Sending RenderProductIssues request\");\n\n RenderProductIssuesResponse response = client.renderProductIssues(request);\n\n System.out.println(\"The full response:\");\n System.out.println(response);\n\n System.out.println(\"-----------------------------------------------------------------\");\n System.out.println(\n \"Summary: \" + response.getRenderedIssuesCount() + \" issues found for the product\");\n System.out.println(\"-----------------------------------------------------------------\");\n\n for (RenderedIssue issue : response.getRenderedIssuesList()) {\n System.out.println(); // empty line for formatting\n SimpleRenderer.printIssue(issue);\n }\n } catch (Exception e) {\n System.out.println(\"An error has occured: \");\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) throws Exception {\n Config config = Config.load();\n String timeZone = \"Europe/Zurich\";\n String languageCode = \"en_GB\";\n // The simple option: request all complex actions to be handled as redirects to\n // the Merchant Center. e.g. send the merchant to MC to request an appeal.\n UserInputActionRenderingOption inputActionOption =\n UserInputActionRenderingOption.REDIRECT_TO_MERCHANT_CENTER;\n // An ID assigned to a product by Google. In the format\n // channel~contentLanguage~feedLabel~offerId\n String productId = \"online~en~label~sku123\";\n\n renderProductIssuesSample(config, productId, languageCode, timeZone, inputActionOption);\n }\n } \n https://github.com/google/merchant-api-samples/blob/c6de994268c785ce22af0065932518a9ac5b3c03/java/src/main/java/shopping/merchant/samples/issueresolution/v1/RenderProductIssuesSample.java"]]