Last active
June 13, 2023 17:34
-
-
Save Webmasterei/5927a93cc1b4827d4e63e465f8bc46a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Hourly Updates for Google Merchant Center Main Feeds | |
| // Fill the arrray with merchant center ids | |
| // Set the script to "hourly" | |
| var MCIDS = [ | |
| "123456", // mein-shop.de | |
| ]; | |
| function main() { | |
| MCIDS.forEach(function(MCID){ | |
| var fetchedFeeds = fetchEnabledProductFeeds(MCID); | |
| Logger.log(fetchedFeeds) | |
| }); | |
| } | |
| function fetchEnabledProductFeeds(merchantId) { | |
| var fetchedFeeds = []; | |
| var date = new Date(); | |
| var now = Utilities.formatDate(date, AdsApp.currentAccount().getTimeZone(), "yyyy MMM dd HH:mm"); | |
| try { | |
| var productFeeds = ShoppingContent.Datafeeds.list(merchantId); | |
| } catch(e) { | |
| Logger.log("### ERROR Fecthing data from merchant: '"+merchantId+"' --> "+e); | |
| fetchedFeeds.push([now, merchantId, , , "### ERROR Fecthing datafeed: "+e]); | |
| return fetchedFeeds; | |
| } | |
| if (productFeeds.resources) { | |
| for (var i = 0; i < productFeeds.resources.length; i++) { | |
| try { | |
| var dataFeedId = productFeeds.resources[i].id; | |
| var response = ShoppingContent.Datafeeds.fetchnow(merchantId, dataFeedId); | |
| fetchedFeeds.push([now, merchantId, productFeeds.resources[i].name, dataFeedId, "Fetch OK"]); | |
| } catch(e) { | |
| fetchedFeeds.push([now, merchantId, productFeeds.resources[i].name, dataFeedId, "### ERROR Fecthing datafeed: "+e]); | |
| } | |
| } | |
| } | |
| return fetchedFeeds; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment