Skip to content

How to identify products with any of the illegal characters in SKU?

Magento 2.4.5-p1

I have imported some products from Magento 1.9 into my Magento 2.x and now I have the issue where I get the following Error when viewing products in the Admin panel:

Something went wrong with processing the default view and we have restored the filter to its original state.

I´ve used a script which I ran in the PhpMyAdmin to identify SKUs with spaces and dots and I have corrected these but apparently we now have other illegal characters also.

What kind of a script could I run in PhpMyAdmin to highlight all products that have illegal characters (anything other than letters, numbers, dashes and underscores) in SKUs?

Also, is there a script that would check to make sure no SKUs are over 64 characters long?