[英]Replace custom CSV file with another CSV file in Google drive using Google scripts
[英]Using AdWords Scripts, how can I replace a feed in Merchant Center with a .txt file from Google Drive?
當IT在我們的網站上進行更新時,我們必須關閉購物廣告,否則由於Google錯誤,我們的流量將會停止幾天。 為此,我們通常會有人手動將新的.txt Feed文件上傳到Merchant Center,所有產品都列為“缺貨”,然后當網站恢復時,我們會重新上傳.txt Feed文件並恢復產品。
問題是我們可以使用Merchant Center中的“規則”工具將所有產品設置為“缺貨”,但我們不能使用相同的規則將所有產品設置為“有庫存”,因為某些商品實際上已經存在庫存
在腳本中,它足夠簡單,可以連接到Merchant Center和Feed,現在我只是想知道如何從Google Drive到Merchant Center獲取.txt文件。
function PullPauseFeed(){
var filesIterator = DriveApp.getFilesByName('Google_Mex_Feed_2016-10-21_OUT OF STOCK.txt');
while (filesIterator.hasNext()) {
var file = filesIterator.next().getAs('text/plain');
}
return file;
}
function MexPause() {
var merchantId = '1111';
var datafeedId = '1111';
var newFeed = PullPauseFeed();
ShoppingContent.Datafeeds.update(newFeed, merchantId, datafeedId);
}
您可能想嘗試外部數據集成 。
這是一項AdWords腳本功能,可讓您與外部數據源集成,例如Google雲端硬盤中的Google電子表格。 AdWords腳本允許您通過SpreadsheetApp界面從電子表格中讀取數據並將數據寫入電子表格 。
在您使用Google雲端硬盤中的.txt
文件的情況下,您可以選擇通過DriveApp界面進一步利用Google雲端硬盤。 這允許腳本在Google雲端硬盤上創建,查找和修改任意文件。
請嘗試瀏覽給定的文檔,並查看可以使用的可用方法或屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.