Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JoryHogeveen/f32e552b94a16e49cbee4aeb8f57f091 to your computer and use it in GitHub Desktop.
Save JoryHogeveen/f32e552b94a16e49cbee4aeb8f57f091 to your computer and use it in GitHub Desktop.
Magento 2 - Admin console - Autofill empty swatch values
// Autofill everything:
jQuery('#swatch-text-options-panel tbody tr').each( function() { var $tr = jQuery(this); var val = $tr.find( 'td:nth-child(4) input' ).val(); $tr.find( 'td:nth-child(3) input' ).val(val); } );
// Autofill empty only:
jQuery('#swatch-text-options-panel tbody tr').each( function() { var $tr = jQuery(this); var val = $tr.find( 'td:nth-child(4) input' ).val(); var target = $tr.find( 'td:nth-child(3) input' ); if ( ! target.val() ) { target.val(val) } } );
@JoryHogeveen
Copy link
Author

JoryHogeveen commented Dec 18, 2024

Just copy one of the lines below in your browser console to autofill swatch fields from it's label/description value. Afterwards you can finetune manually and save the attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment