Это то, что я закончил
$sku = str_replace("LS", "", $this->SKU, $count);
if ($count > 0) {
$ls = strpos($this->SKU, 'LS');
$num1 = substr($this->SKU, $ls+2, 2);
$num2 = substr($this->SKU, $ls+4, 2);
$num3 = substr($this->SKU, $ls+6, 2);
if ((int) $num1 < 10) {
$num1 = str_replace("01", "1", $num1);
$num1 = str_replace("02", "2", $num1);
$num1 = str_replace("03", "3", $num1);
$num1 = str_replace("04", "4", $num1);
$num1 = str_replace("05", "5", $num1);
$num1 = str_replace("06", "6", $num1);
$num1 = str_replace("07", "7", $num1);
$num1 = str_replace("08", "8", $num1);
$num1 = str_replace("09", "9", $num1);
//replace original num1 with new single digit num1 in $sku
$sku = str_replace(substr($this->SKU, $ls+2, 2), $num1, $sku);
}
if ((int) $num2 < 10 && ($num1 != $num2)) {
$num2 = str_replace("01", "1", $num2);
$num2 = str_replace("02", "2", $num2);
$num2 = str_replace("03", "3", $num2);
$num2 = str_replace("04", "4", $num2);
$num2 = str_replace("05", "5", $num2);
$num2 = str_replace("06", "6", $num2);
$num2 = str_replace("07", "7", $num2);
$num2 = str_replace("08", "8", $num2);
$num2 = str_replace("09", "9", $num2);
$sku = str_replace(substr($this->SKU, $ls+4, 2), $num2, $sku);
}
if ((int) $num3 < 10 && ($num2 != $num3) && ($num1 != $num3)) {
$num3 = str_replace("01", "1", $num3);
$num3 = str_replace("02", "2", $num3);
$num3 = str_replace("03", "3", $num3);
$num3 = str_replace("04", "4", $num3);
$num3 = str_replace("05", "5", $num3);
$num3 = str_replace("06", "6", $num3);
$num3 = str_replace("07", "7", $num3);
$num3 = str_replace("08", "8", $num3);
$num3 = str_replace("09", "9", $num3);
$sku = str_replace(substr($this->SKU, $ls+6, 2), $num3, $sku);
}
$this->SKU = $sku;
$this->save();