doudang9147 2015-02-23 11:08
浏览 49
已采纳

在prestashop错误中上传类别语言

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条回答 默认 最新

  • dqf67993 2015-02-24 08:54
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏