CSV 导入正在用 _ 替换 < 和 >
CSV import is replacing < and > with _
我有以下代码作为 cron 作业的一部分
if (file_exists(DIR_FS_CATALOG . '/orderwise_imports/Zencart_Product_HTML_Info.csv')) {
$fileName = DIR_FS_CATALOG . '/orderwise_imports/Zencart_Product_HTML_Info.csv';
$file = fopen($fileName, "r");
fgetcsv($file, 0, ";", '|'); // read the first line and do nothing with it as we don't need to write the cell names to the database
while ( ($column = fgetcsv ( $file, 0, ';', '|' )) !== FALSE ) {
$column = array_map(function ($string) {
$string2 = zen_db_prepare_input($string);
return str_replace("'", "\'", $string2);
}, $column);
csv 条目之一的示例是
|2312|;|2312|;|EP-9SS-B-001|;|<p><strong>NINE bars deliver 9 great vitamin and mineral benefits for physical and mental energy in an easy to consume format, perfect for people on the go.</strong></p><p>Start your day the right way… this perfectly balanced NINE offers a healthy helping of satisfying oats and a tangy-sweet Berry flavour with the added staple of nutritious sunflower, pumpkin, sesame and hemp seeds for the perfect combination of Good Seeds and Great Tastes.</p><p><strong>USP: </strong>Made with natural seeds such as sunflower, pumpkin, sesame and chia.</p><p><strong>WOW FACT! </strong>Naturally vegan friendly range and poweredwith 100% plant protein.</p><p><strong>Lifestyle & Dietary trends: </strong>Vegan; Source of Protein; Gluten Free.</p>|;|1459|
所有开始和结束 html 标签都被替换为下划线。如果我这样做
print_r($column);
我看到了
Array ( [0] => 2312 [1] => 2312 [2] => EP-9SS-B-001 [3] => _p__strong_NINE bars deliver 9 great vitamin and mineral benefits for physical and mental energy in an easy to consume format, perfect for people on the go._/strong__/p__p_Start your day the right way… this perfectly balanced NINE offers a healthy helping of satisfying oats and a tangy-sweet Berry flavour with the added staple of nutritious sunflower, pumpkin, sesame and hemp seeds for the perfect combination of Good Seeds and Great Tastes._/p__p__strong_USP: _/strong_Made with natural seeds such as sunflower, pumpkin, sesame and chia._/p__p__strong_WOW FACT! _/strong_Naturally vegan friendly range and poweredwith 100% plant protein._/p__p__strong_Lifestyle & Dietary trends: _/strong_Vegan; Source of Protein; Gluten Free._/p_ [4] => 1459 )
我一辈子都弄不明白为什么会这样。以前有人遇到过这个问题,你是怎么解决的?
zen_db_prepare_input 进行转换。
检查这个:
http://phpcrossref.com/xref/zencart/includes/functions/functions_general.php.html#zen_db_prepare_input
第 865 行和第 105 行
我有以下代码作为 cron 作业的一部分
if (file_exists(DIR_FS_CATALOG . '/orderwise_imports/Zencart_Product_HTML_Info.csv')) {
$fileName = DIR_FS_CATALOG . '/orderwise_imports/Zencart_Product_HTML_Info.csv';
$file = fopen($fileName, "r");
fgetcsv($file, 0, ";", '|'); // read the first line and do nothing with it as we don't need to write the cell names to the database
while ( ($column = fgetcsv ( $file, 0, ';', '|' )) !== FALSE ) {
$column = array_map(function ($string) {
$string2 = zen_db_prepare_input($string);
return str_replace("'", "\'", $string2);
}, $column);
csv 条目之一的示例是
|2312|;|2312|;|EP-9SS-B-001|;|<p><strong>NINE bars deliver 9 great vitamin and mineral benefits for physical and mental energy in an easy to consume format, perfect for people on the go.</strong></p><p>Start your day the right way… this perfectly balanced NINE offers a healthy helping of satisfying oats and a tangy-sweet Berry flavour with the added staple of nutritious sunflower, pumpkin, sesame and hemp seeds for the perfect combination of Good Seeds and Great Tastes.</p><p><strong>USP: </strong>Made with natural seeds such as sunflower, pumpkin, sesame and chia.</p><p><strong>WOW FACT! </strong>Naturally vegan friendly range and poweredwith 100% plant protein.</p><p><strong>Lifestyle & Dietary trends: </strong>Vegan; Source of Protein; Gluten Free.</p>|;|1459|
所有开始和结束 html 标签都被替换为下划线。如果我这样做
print_r($column);
我看到了
Array ( [0] => 2312 [1] => 2312 [2] => EP-9SS-B-001 [3] => _p__strong_NINE bars deliver 9 great vitamin and mineral benefits for physical and mental energy in an easy to consume format, perfect for people on the go._/strong__/p__p_Start your day the right way… this perfectly balanced NINE offers a healthy helping of satisfying oats and a tangy-sweet Berry flavour with the added staple of nutritious sunflower, pumpkin, sesame and hemp seeds for the perfect combination of Good Seeds and Great Tastes._/p__p__strong_USP: _/strong_Made with natural seeds such as sunflower, pumpkin, sesame and chia._/p__p__strong_WOW FACT! _/strong_Naturally vegan friendly range and poweredwith 100% plant protein._/p__p__strong_Lifestyle & Dietary trends: _/strong_Vegan; Source of Protein; Gluten Free._/p_ [4] => 1459 )
我一辈子都弄不明白为什么会这样。以前有人遇到过这个问题,你是怎么解决的?
zen_db_prepare_input 进行转换。 检查这个: http://phpcrossref.com/xref/zencart/includes/functions/functions_general.php.html#zen_db_prepare_input 第 865 行和第 105 行