Jump to content

How to enable special characters in supplier reference field?


Recommended Posts

It is the following function on line 411 of classes/Validate.php (in PrestaShop v1.3) that validates the reference fields:

static public function isReference($reference)
{
   return preg_match('/^[^<>;={}]*$/ui', $reference);
}



Remove the characters from there that you want to include in the reference field.

Link to comment
Share on other sites

It is pSQL($supplier_reference) in classes/Product.php, strip-tags for pSQL comes from classes/db.php, so I just removed the pSQL and leaving it just ($supplier_reference) and it works. Or will it break something else now?

Link to comment
Share on other sites

  • 2 weeks later...

Now there is the same thing with importing: it says

# (ID 2922) cannot be saved
# You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'http://www......
at the supplier reference field. What is it that prevents special characters to be imported?
Link to comment
Share on other sites

I'm not sure what is causing that error. Are you importing attributes? The only thing I could find was the following on line 703 of Product.php in the addProductAttribute function:

'weight' => ($weight ? floatval($weight) : 0), 'reference' => pSQL($reference), 'supplier_reference' => pSQL($supplier_reference), 



which in your case should be:

'weight' => ($weight ? floatval($weight) : 0), 'reference' => pSQL($reference, true), 'supplier_reference' => pSQL($supplier_reference, true), 



I also found the following on lines 417-418 in the getByReference function that you'll need to comment out:

if (!Validate::isReference($reference))
   die(Tools::displayError());

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...