0

We have a 3rd party module that needs PHP script to customize the upload of a stock update.

Like the file we get it has SKU name with space "-" and "/". But the SKU in MAgento do not.

So i created a script that removes "/" and "-" and another script that trims the cell.

Each script works sepretly but not together. Anyone that can help me with what is wrong?

<?php
 /* Your custom script */
return str_replace(['/','-','.',','],'', $self);
return trim($cell [0]);

2 Answers 2

0

As per your code, You have added 2 return statement so second line code will never get executed.

Instead of this create a variable and last line should return final output

0

The issue with your script is that you have two return statements one after the other. In PHP, once a return statement is executed, the function exits, and any code after the first return will not be executed.

Here’s your modified code as below,

<?php
/* Your custom script */
$cleanedCell = str_replace(['/','-','.',','], '', $cell[0]);
return trim($cleanedCell);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.