Insert a product
function insertProduct() {
var merchantId = 'INSERT_MERCHANT_ID_HERE';
// Create a product resource. See
// https://developers.google.com/shopping-content/v2/reference/v2/products
// for the full list of fields supported by product resource.
var productResource = {
'offerId': 'book123',
'title': 'A Tale of Two Cities',
'description': 'A classic novel about the French Revolution',
'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': 'in stock',
'condition': 'new',
'googleProductCategory': 'Media > Books',
'productType': 'Media > Books',
'gtin': '9780007350896',
'price': {
'value': '2.50',
'currency': 'USD'
},
'shipping': [{
'country': 'US',
'service': 'Standard shipping',
'price': {
'value': '0.99',
'currency': 'USD'
}
}],
'shippingWeight': {
'value': '2',
'unit': 'pounds'
}
};
ShoppingContent.Products.insert(productResource, merchantId);
}
List all products
function listProducts() {
var merchantId = 'INSERT_MERCHANT_ID_HERE';
// List all the products for a given merchant.
var products = ShoppingContent.Products.list(merchantId);
if (products.resources) {
for (var i = 0; i < products.resources.length; i++) {
Logger.log(products.resources[i]);
}
}
}
Insert products using custombatch API
function custombatch() {
var merchantId = 'INSERT_MERCHANT_ID_HERE';
// Create your product resources. See
// https://developers.google.com/shopping-content/v2/reference/v2/products
// for the full list of fields supported by product resource. See the
// insertProduct() snippet for a code example that shows how to construct
// a product resource.
var productResource1 = {
// FILL THIS OUT.
};
var productResource2 = {
// FILL THIS OUT.
};
var productResource3 = {
// FILL THIS OUT.
};
var 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
},
]
};
var response = ShoppingContent.Products.custombatch(custombatchResource);
Logger.log(response);
}
function getAccountInfo() {
var merchantId = 'INSERT_MERCHANT_ID_HERE';
var accountId = 'INSERT_ACCOUNT_ID_HERE';
// See https://developers.google.com/shopping-content/v2/reference/v2/accounts
// for the list of fields supported by Account type.
var accounts = ShoppingContent.Accounts.get(merchantId, accountId);
Logger.log(accounts);
// See https://developers.google.com/shopping-content/v2/reference/v2/accountstatuses
// for the list of account status fields supported by Shopping Content API.
var accountstatuses = ShoppingContent.Accountstatuses.get(merchantId,
accountId);
Logger.log(accountstatuses);
// See https://developers.google.com/shopping-content/v2/reference/v2/accountshipping
// for various Account shipping settings fields supported by Shopping
// Content API..
var accountshipping = ShoppingContent.Accountshipping.get(merchantId,
accountId);
Logger.log(accountshipping);
// See https://developers.google.com/shopping-content/v2/reference/v2/accounttax
// for various Account tax fields supported by Shopping Content API.
var accounttax = ShoppingContent.Accounttax.get(merchantId, accountId);
Logger.log(accounttax);
}