Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshvardhanmalpani/93cc0cbbd5cf78534cb674b8ce8205c0 to your computer and use it in GitHub Desktop.
Save harshvardhanmalpani/93cc0cbbd5cf78534cb674b8ce8205c0 to your computer and use it in GitHub Desktop.
Manage Magento 2 product attribute options - values using JS console
$jq=new jQuery.noConflict();
var mimim=["Abalone",
"Titanium Druzy",
"Tourmaline",
"Turquoise",
"Yellow Zircon",
"Light Blue Druzy"];
var trans=[];var o=0;
$jq('#manage-options-panel tbody tr td:nth-child(3) input').each(
function(a,b){
//if(a>10)return false;
//alert(b.value);
trans.push(b.value);
if($jq.inArray(b.value,mimim)==-1){ o++;$jq('#delete_button_'+b.name.slice(14,-4)).click(); trans.pop();}
});
alert(o+" items removed");
$jq.each(mimim,function(a,b){
//console.log($jq('#manage-options-panel tbody tr td:nth-child(3) input').val());
if($jq.inArray(b,trans)==-1){
$jq('#add_new_option_button').click();
$jq('#manage-options-panel tbody tr:last-child td:nth-child(3) input').val(b);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment