skip to Main Content

I’m trying to migrate categories from osCommerce 2.2 to the newest Prestashop using the Prestashop’s own CSV import. I have succeeded in uploading English, Finnish, Deutch, Italian and French category languages. I am now facing a problem with Russian. The CSV file imports just fine until row 85-86, which are:

85;"Соусы для чипсов";"Чипсы, орехи, и снаксы";;http://localhost/images/pepper.jpg;соусы-для-чипсов

86;"Чипсы, орехи, и снаксы";"Финские продукты питания";"<strong>Внимание! ПРОЧИТАЙТЕ ПРЕЖДЕ, ЧЕМ СДЕЛАТЬ ЗАКАЗ</strong>Поскольку пакеты со снаксами занимают очень много места, нам приходится закладывать в стоимость их доставки двойной вес, т.е., например, для пакета весом 250 г. стоимость доставки будет такой же, как для 500 г. более плотного товара.""<em>Стоимость доставки определяется по объемному весу или по фактическому весу, в зависимости от того, что больше.</em>""<a target=""_blank"" href=""http://www.posti.fi/hinnat/paketitulkomaille/"">http://www.posti.fi</a>";http://localhost/images/sips.jpg;чипсы-орехи-и-снаксы

Note that the line 84 goes through:

84;"Переведенные на финский книги";Книги;;http://localhost/images/potter.jpg;переведенные-на-финский-книги

To clarify the CSV for you:

ID;Name;Parent;Description;Img_uri;Url_rewrite

It throws a long error, but the highlights are at the beginning:

Чипсы, орехи, и снаксы (ID: null) cannot be saved
Property Category->link_rewrite is not valid
Соусы для чипсов (ID: 85) cannot be saved
Чипсы, орехи, и снаксы (ID: 86) cannot be saved

For some reason the ID is null, this could be the reason or a symptom?

The SEO link rewrite is converted from the category name in SQL like this:

LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(cd.categories_name, ' ', '-'), "'", ''), ',', ''), '.', '-'), '&', ''), '(', '-'), ')', '-'), '!', ''), '/', '-'), '+', '-'), ';', '')) AS URL_rewrite

I know thats a very ugly way to do it, but as far as I know, the one and only best option I have.

Noting that the first 80 lines go through properly, it’s not the language that fails this import, in French language it threw the same error because there was a “;” character in the description, I can’t see anything wrong here, I hope one of you could help me with this

Thank you in advance!

2

Answers


  1. Chosen as BEST ANSWER

    I did not find a rational explanation for this, so I just went around and changed the link_rewrite validation just to return true no matter what. Checked and the link works. Hope this someday helps someone.

    In ROOT/Classes/Validate.php

    On line 325:

    public static function isLinkRewrite($link)
    {
        if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
            return preg_match('/^[_a-zA-Z0-9-pL]+$/u', $link);
        return preg_match('/^[_a-zA-Z0-9-]+$/', $link);
    }
    

    Change it to:

    public static function isLinkRewrite($link)
    {
        if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
        //  return preg_match('/^[_a-zA-Z0-9-pL]+$/u', $link);
        //return preg_match('/^[_a-zA-Z0-9-]+$/', $link);
        return true;
    }
    

    Just remember to revert the changes after the upload


  2. There is a setting in the URL/SEO tab that allows or disallows non-Latin (e.g. Cyrillic) characters. This code basically checks for this.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search