Created
November 22, 2017 09:55
-
-
Save harshvardhanmalpani/93cc0cbbd5cf78534cb674b8ce8205c0 to your computer and use it in GitHub Desktop.
Manage Magento 2 product attribute options - values using JS console
This file contains 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
$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