Jump to content

Allow special characters in product Name \ Reference fields


Recommended Posts

Hello,

I'm trying to allow More characters in the product Name and Reference fields when i'm adding \ editing a product,

 

I've searched in the informations.tpl file (admin\themes\default\template\controllers\products\informations.tpl)

and in classess\Product.php

which looked like the files i'll find it in, and i just can't find anything,

Can someone give me a hint about Where i define which character is allowed and which is forbidden?

(If you ask i need to add characters that normally found in a URL, Like = & + etc.)

 

Thank you!

Link to comment
Share on other sites

Hi for this you have to override the validate.php class on the override folder

 

class Validate extends ValidateCore
{
   /**
    * Check for product or category name validity
    *
    * @param string $name Product or category name to validate
    * @return boolean Validity is ok or not
    */
   public static function isCatalogName($name)
   {
       return preg_match('/^[^<>;=#{}]*$/u', $name); //This function del this characters on your name var.
   }
}

 

Tell me if it's ok ;)

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

I had the same problem, and did the same.

 

The question is : are there any good reason why those characters were forbidden at some point or is this jus an arbitrary convention?? If yes removing this validation removal could have some pretty weird effects...

 

Even though according to me all names & fields should/are escaped (so basically there should be no problem whith =;<> )...

 

Does anybody has an idea about that point ? These default could be related to import, filtering...

 

Stéphane.

  • Like 1
Link to comment
Share on other sites

  • 4 years later...

Hello,

 

I have a CSV to import, but a lot of products have special characters in product name, reference, meta title and meta description.

 

I changed:

 

public static function isCatalogName($name)
    {
        // return preg_match('/^[^<>;=#{}]*$/u', $name);
        return preg_match('/^$/u', $name);
                
    }

 

and

 

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

 

I succeded to import the products with "#" character but I still can't import products with ">" and "=" characters

 

Any idea?

 

Thank you very much.

Link to comment
Share on other sites

×
×
  • Create New...