我有prestashop。使用IMPORTOSC模块输入数据。
一切都很好,只发出其中有空格的图像,其名称未导入prestashop。(URL中的空格)
类别导入代码:
public function getCategories($limit = 0, $nrb_import = 100) {
$multiLangFields = array('name', 'link_rewrite');
$keyLanguage = 'id_lang';
$identifier = 'id_category';
$categories = $this->ExecuteS('
SELECT c.categories_id as id_category, c.parent_id as id_parent, 0 as level_depth, cd.language_id as id_lang, cd.categories_name as name , 1 as active, categories_image as images
FROM `'.bqSQL($this->prefix).'categories` c
LEFT JOIN `'.bqSQL($this->prefix).'categories_description` cd ON (c.categories_id = cd.categories_id)
WHERE cd.categories_name IS NOT NULL AND cd.language_id IS NOT NULL
ORDER BY c.categories_id, cd.language_id
LIMIT '.(int)($limit).' , '.(int)$nrb_import);
foreach($categories as& $cat)
{
$cat['link_rewrite'] = Tools::link_rewrite($cat['name']);
$cat['images'] = array(Tools::getProtocol().Tools::getValue('shop_url').'/images/'.$cat['images']);
}
return $this->autoFormat($categories, $identifier, $keyLanguage, $multiLangFields);
}
我搜索了它看起来像是,它可能由str_replace('','%20',trim($ url))修复
有人可以帮我处理代码。
答案 0 :(得分:0)
而不是str_replace()
,请使用urlencode()
(有关详细信息,请参阅PHP manual)。 urlencode()
函数正确编码除“ - ”和“_”之外的所有非字母字符。