Bulk edit products, manipulate data any way you like for free!

Bulk edit products, manipulate data any way you like for free!

Turtlebite
Tourist
3 0 2

Hi . I like to share a simple solution to edit any data of products. I needed to change all prices of 5 variants of 200 products. I didn't want to do it manually in the shopify bulk editor and didn't want to by an app, there should be a free way. And there is: Just export all products as CSV, than import it in Google sheets. There you can create an App Script and now you are able to do whatever you like, because you have access to all cells in the data sheet and can script it all. Here is an example for adding 4 USD to the prices:

******************************************************************************************************

function changePrices() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var opt1ValArr = sheet.getRange('J:J').getValues();
  var priceArr = sheet.getRange('W:W').getValues();
   // Only execute for Posters (A4,A3,A2,A1,A0):
  var reg = "^(A4|A3|A2|A1|A0)";
  for (var i = 0; i < priceArr.length; i++) {
    var found = new RegExp(reg).test(String(opt1ValArr[i]));
    if (found) {
      var amount = 4;
      // make sure there are 2 decimal points and and text format is converted to number
      var newPrice = Math.round((parseFloat(priceArr[i]) + amount) * 100) / 100;
     // Feedback in console:
      Logger.log(opt1ValArr[i] +": "+ priceArr[i] + ", new: " + newPrice);
      // Finally add the 4 USD to all prices:
      sheet.getRange('W' + (i+1)).setValue(newPrice);
    }
  }
};
 
Or, another example: I had a metatag, which I wanted to move its content to the tags:
 
function cleanupMetatags() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var metaTagArr = sheet.getRange('AT:AT').getValues();
  for (var i = 1; i < metaTagArr.length; i++) {
    if (metaTagArr[i].toString() != "") {
      Logger.log(i+" - Metatag gefunden: " + metaTagArr[i]);
      // If MetaTag field is not empty, clean up value (replace characters and remove new lines)...
      var t = metaTagArr[i].toString().replaceAll(', ', ' | ',);
      t = t.replaceAll('\n',',');
      //...after that copy the new value to the other field in column G:
      Logger.log(i+" - Metatag cleaned: " + t);
      sheet.getRange('G' + (i+1)).setValue(t);
      // Now empty all values in column AT:
      sheet.getRange('AT' + (i+1)).setValue('');
    }
  }
  // Give some feedback it there are still values found:
  var check = false;
  metaTagArr = sheet.getRange('AT:AT').getValues();
  for (var i = 1; i < metaTagArr.length; i++) {
    if (metaTagArr[i].toString() != "") {
      check = true;
      Logger.log("Metatag gefunden: "+metaTagArr[i]);
    }
  }
  if (check == false) {
    Logger.log("=========================================");
    Logger.log("No more Metatags found.");
    Logger.log("=========================================");
  }
  debugger
}

String.prototype.replaceAll = function(search, replacement) {
        var target = this;
        return target.replace(new RegExp(search, 'g'), replacement);
};
**********************************************************************************
 
With Google Sheets and Apps Scripts I can now do whatever I can imagine and it's all free. Want to add 1 USD to all products of Type Poster with size A3 and the string "moody" in the handle? No problem any longer. 🙂

Let me know what you think! 
 

 

 

Replies 0 (0)