쇼핑 콘텐츠 서비스를 사용하면 Apps Script에서 Google Content API for Shopping을 사용할 수 있습니다. 이 API를 사용하면 Google 판매자 센터 사용자가 제품 등록정보를 업로드 및 관리하고 판매자 센터 계정을 관리할 수 있습니다.
이 서비스에 관한 자세한 내용은 쇼핑용 Google Content API의 참조 문서를 참고하세요. Apps Script의 모든 고급 서비스와 마찬가지로 쇼핑 콘텐츠 서비스는 공개 API와 동일한 객체, 메서드, 매개변수를 활용합니다.
참조
이 서비스에 관한 자세한 내용은 Google Content API for Shopping API의 참조 문서를 참고하세요. Apps Script의 모든 고급 서비스와 마찬가지로 고급 Sheets 서비스는 공개 API와 동일한 객체, 메서드, 매개변수를 사용합니다. 자세한 내용은 메서드 서명 결정 방법을 참고하세요.
/** * Inserts a product into the products list. Logs the API response. */functionproductInsert(){constmerchantId=123456;// Replace this with your Merchant Center ID.// Create a product resource and insert itconstproductResource={'offerId':'book123','title':'ATaleofTwoCities','description':'AclassicnovelabouttheFrenchRevolution','link':'http://my-book-shop.com/tale-of-two-cities.html','imageLink':'http://my-book-shop.com/tale-of-two-cities.jpg','contentLanguage':'en','targetCountry':'US','channel':'online','availability':'instock','condition':'new','googleProductCategory':'Media > Books','productType':'Media > Books','gtin':'9780007350896','price':{'value':'2.50','currency':'USD'},'shipping':[{'country':'US','service':'Standardshipping','price':{'value':'0.99','currency':'USD'}}],'shippingWeight':{'value':'2','unit':'pounds'}};try{response=ShoppingContent.Products.insert(productResource,merchantId);// RESTful insert returns the JSON object as a response.console.log(response);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log('Failedwitherror:$s',e.error);}}
/** * Lists the products for a given merchant. */functionproductList(){constmerchantId=123456;// Replace this with your Merchant Center ID.letpageToken;letpageNum=1;constmaxResults=10;try{do{constproducts=ShoppingContent.Products.list(merchantId,{pageToken:pageToken,maxResults:maxResults});console.log('Page'+pageNum);if(products.resources){for(leti=0;i < products.resources.length;i++){console.log('Item['+i+']==>'+products.resources[i]);}}else{console.log('Nomoreproductsinaccount'+merchantId);}pageToken=products.nextPageToken;pageNum++;}while(pageToken);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log('Failedwitherror:$s',e.error);}}
/** * Batch updates products. Logs the response. * @param {object} productResource1 The first product resource. * @param {object} productResource2 The second product resource. * @param {object} productResource3 The third product resource. */functioncustombatch(productResource1,productResource2,productResource3){constmerchantId=123456;// Replace this with your Merchant Center ID.custombatchResource={'entries':[{'batchId':1,'merchantId':merchantId,'method':'insert','productId':'book124','product':productResource1},{'batchId':2,'merchantId':merchantId,'method':'insert','productId':'book125','product':productResource2},{'batchId':3,'merchantId':merchantId,'method':'insert','productId':'book126','product':productResource3}]};try{constresponse=ShoppingContent.Products.custombatch(custombatchResource);console.log(response);}catch(e){// TODO (Developer) - Handle exceptionsconsole.log('Failedwitherror:$s',e.error);}}
계정 수준 세금 업데이트
이 샘플 코드는 Accounttax를 사용하여 판매자 센터 계정의 계정 수준 세금 정보를 업데이트합니다. 계정 수준 세금 및 배송에 관한 자세한 내용은 API 가이드를 참고하세요.
/** * Updates content account tax information. * Logs the API response. */functionupdateAccountTax(){// Replace this with your Merchant Center ID.constmerchantId=123456;// Replace this with the account that you are updating taxes for.constaccountId=123456;try{constaccounttax=ShoppingContent.Accounttax.get(merchantId,accountId);console.log(accounttax);consttaxInfo={accountId:accountId,rules:[{'useGlobalRate':true,'locationId':21135,'shippingTaxed':true,'country':'US'},{'ratePercent':3,'locationId':21136,'country':'US'},{'ratePercent':2,'locationId':21160,'shippingTaxed':true,'country':'US'}]};console.log(ShoppingContent.Accounttax.update(taxInfo,merchantId,accountId));}catch(e){// TODO (Developer) - Handle exceptionsconsole.log('Failedwitherror:$s',e.error);}}
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[[["The Shopping Content Service lets you manage Google Merchant Center product listings and accounts within Apps Script using the Google Content API for Shopping."],["This is an advanced service that requires enabling before use and mirrors the functionality of the public API."],["Provided code samples demonstrate common tasks like inserting, listing, and batch-updating products, as well as updating account-level tax information."],["For comprehensive details, consult the Google Content API for Shopping reference documentation and support guide linked within the content."]]],[]]