Skip to content

Instantly share code, notes, and snippets.

@thisislawatts
Last active August 29, 2015 14:17
Show Gist options
  • Save thisislawatts/87eb1ab9207a8ec30729 to your computer and use it in GitHub Desktop.
Save thisislawatts/87eb1ab9207a8ec30729 to your computer and use it in GitHub Desktop.
Shopify - Bulk Redirect Import
var directs = [{
old: "/i-am-an-old-url",
new: "/i-am-your-new-url"
}];
var counter = 0;
var $addURLRedirect = jQuery('a[bind-event-click*="addUrlRedirectModal"]');
var currentRedirect;
addRedirect = function() {
$addURLRedirect.trigger('click');
setTimeout(function() {
currentRedirect = directs[counter];
jQuery('#redirect_path').val(currentRedirect['old']);
jQuery('#redirect_target').val(currentRedirect['new']).trigger('change');
jQuery('.new_redirect .js-btn-primary').trigger('click');
counter++;
if ( counter < directs.length ) {
setTimeout(function() {
addRedirect();
}, 800);
}
}, 1500);
}
addRedirect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment