Jump to content

[Solved] Importing CSV with special characters to meta-title


xfdisco
 Share

Recommended Posts

We like to import all products from our ERP system. The import module seems to fullfill our requirements. But after the first import we've figured out that there is problem with our product titles.

We have created an CSV file with all information from our ERP with proper structure. Meta-title is the same like the product title.

The problem is that we have several products which have inequality signs (angle brackets) or equal signs in their product titles. This produces error messages after the import for these articles.

 

See protocoll:

 

Einblasschlauch NW75 (3''), L=15m (ID: 074) kann nicht gespeichert werden
Property Product->meta_title is not valid
Einblasschlauch NW63 (2 ½''), L=15m (ID: 166) kann nicht gespeichert werden
Einblasschlauch NW50 (2''), L=15m (ID: 167) kann nicht gespeichert werden

...

kann nicht gespeichert werden = can not be saved

 

Does anybody have an idea to configure the import presets for that? We can't change the product names because the customers are used to that.

 

Many thanks in advance!

Edited by xfdisco (see edit history)

Share this post


Link to post
Share on other sites

Hui – nice idea. We tried that but Prestashop gave another error message…

 

5 Fehler 

  1. Einblasschlauch NW75 (3''), L=15m (ID: 074) kann nicht gespeichert werden
  2. Property Product->name is not valid
  3. Einblasschlauch NW63 (2 ½''), L=15m (ID: 166) kann nicht gespeichert werden
  4. Einblasschlauch NW50 (2''), L=15m (ID: 167) kann nicht gespeichert werden
  5. Schnellkupplung-Übergangsstück Kn89>Kn66 (ID: 173) kann nicht gespeichert werden

…any other ideas? It does not accept html equivalents :-(

Share this post


Link to post
Share on other sites

Wait...

 

Try it:

 

Einblasschlauch NW75 (3''), L=15m (ID: 074)
Einblasschlauch NW63 (2 ½''), L=15m (ID: 166) 
Einblasschlauch NW50 (2''), L=15m (ID: 167)
 
I search another solution meanwhile.

Share this post


Link to post
Share on other sites

I don't believe it...

 

When you try to import your file, you tick ISO 8859-1 encoded file option?

 
Can you try to open your file with notepad++ and resave it but make sure you change the encoding by going to the menu "Encoding --> Convert to UTF-8 without BOM", not "Encoding --> Encode in UTF-8 without BOM"
 
Edited by TribalDexterD (see edit history)

Share this post


Link to post
Share on other sites

Good morning TribalDexterD,

many thanks for the tips again! We tried conversion with Notepad++ to utf-8 without BOM but didn't suceed. Formerly I used Medit for encoding. I am not sure if it really did the same. So we used Notepad++.

Prestashop gives us still the same error messages: meta-title not vaild.

 

We also checked the html equivalents with the utf-8-method. This did also not help. Prestashop seems not to like the # I think. Also it looks like equals sign and inequality signs are not allowed in the name field:

 

4 Fehler

  1. Einblasschlauch NW75 (3''), L=15m (ID: 074) kann nicht gespeichert werden
  2. Property Product->name is not valid
  3. Einblasschlauch NW63 (2 ½''), L=15m (ID: 166) kann nicht gespeichert werden
  4. Y-Stück NW75/75>75 (3'') (ID: 456) kann nicht gespeichert werden

 

I hope there is a way without chnging much of the source of prestashop. Do have more ideas?

 

Thanks

 

T

Share this post


Link to post
Share on other sites

Hi xfdisco!
 
I've found a simple "fix" for that.
 
So, I don't know why prestashop doesn't want that user write "equals signs" or others special characters on the product's name, product's meta title, etc...
 
However, this is the "fix":
 
root/classes/Product.php
 

 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true,'validate' => 'isGenericName', 'size' => 128),
'name' => array('type' => self::TYPE_STRING, 'lang' => true,'validate' => 'isCatalogName','required' => true, 'size' => 128),

and comment this:
 

 'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true,/*'validate' => 'isGenericName',*/'size' => 128),
'name' => array('type' => self::TYPE_STRING, 'lang' => true,/*'validate' => 'isCatalogName',*/'required' => true, 'size' => 128),

In this way, prestashop will not validate those fields. (product meta title and product name).

 

Otherwise, you can create your own preg_match on root/classes/Validate.php and to associate it to both fields.

Edited by TribalDexterD (see edit history)

Share this post


Link to post
Share on other sites

I'm glad to help you ;)

 

This fix will be overwritten in the moment that you will upgrade PS' core, so remember it.

 

I've followed the logic, in fact I thought "those fields are validated from some file with preg_match" so I've searched for a file with this property and I found Validate.php.

	/**
	 * Check for standard name validity
	 *
	 * @param string $name Name to validate
	 * @return boolean Validity is ok or not
	 */
	public static function isGenericName($name)
	{
		return empty($name) || preg_match(Tools::cleanNonUnicodeSupport('/^[^<>={}]*$/u'), $name);
	}

After that I've searched the file where was present the command to validate those fields and I found Product.php

... 'validate' => 'isGenericName' ...

That's all! :D

 

PS: I'm sorry for my bad english, I'm learning it. :P

Share this post


Link to post
Share on other sites

  • 6 months later...

So, back to the topic.

 

Somehow today, our Solution stopped working. Its not importing anything coming after an ½ in the product name.

So there is yet no Error like back in the days, but its just stoping...

For example:

"NW63 injection hose (2 ½ ''), L 15m " (becomes)-> "NW63 injection hose (2  "

 

Did anything change ? Or is there a problem with our running system ?

It did work quite well since back then.

 

Thanks in advance :)

Share this post


Link to post
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More