-- Replace cyrillic 'x' by lat 'x' when 'x' between numbers
DROP PROCEDURE IF EXISTS replace_char_product_name;
DELIMITER $$
CREATE PROCEDURE replace_char_product_name()
BEGIN
   DECLARE cursor_List_isdone BOOLEAN DEFAULT FALSE;
   DECLARE cur_product_id INT;
   DECLARE cur_name TEXT;
   DECLARE cur_finded TEXT;
   DECLARE cur_replaced TEXT;
   DECLARE cur_new_name TEXT;

   DECLARE cursor_List CURSOR FOR 
    SELECT product_id, name, REGEXP_SUBSTR(name, '[0-9]х[0-9]') AS finded
    FROM oc_product_description 
    WHERE name REGEXP '[0-9]х[0-9]'
    ;

   DECLARE CONTINUE HANDLER FOR NOT FOUND SET cursor_List_isdone = TRUE;

   OPEN cursor_List;

   loop_List: LOOP
      FETCH cursor_List INTO cur_product_id, cur_name, cur_finded;
      IF cursor_List_isdone THEN
        LEAVE loop_List;
      END IF;

      SET cur_replaced = REPLACE(cur_finded, 'х', 'x');
      SET cur_new_name = REPLACE(cur_name, cur_finded, cur_replaced);
      
      UPDATE `oc_product_description` 
      SET `name`=cur_new_name 
      WHERE `product_id`=cur_product_id AND name LIKE cur_name;

   END LOOP loop_List;

   CLOSE cursor_List;
END

$$

DELIMITER ;

CALL replace_char_product_name();