我正在尝试使用CSV导入项目 - 在“可自定义”列中显示“(0 =否,1 =是)”。
我已经阅读过关于此的few other threads,看起来它的格式应该是这样的:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitUseStrict": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
],
"compileOnSave": true,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
但是当我尝试在可自定义列中上传具有该语法的产品时 - 导入失败。
如果我将其更改为1或0,则上传成功;但后来我必须进入每个产品,然后点击自定义,然后点击自定义文本并保存(这是我首先想要使用CSV避免的。)
格式化上传CSV的合适方法是什么,以便可自定义的字段保存得恰当?
我正在使用1.6.1.4。
答案 0 :(得分:0)
不幸的是,它似乎不是默认CSV导入的选项(这是一个无赖)。
我能够通过编写一个小脚本来调整数据库来解决这个问题。
脚本如下所示:
// Create connection
$conn = new mysqli($servername, $username, $password, $database);
/* check connection */
if ($conn->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
echo "Connected successfully<br /><br />";
$conn->query("update ps_category_lang set name=SUBSTRING_INDEX(name, '(', 1) WHERE name REGEXP '([[:digit:]]+)';");
$conn->query("truncate table ps_customization_field;");
$conn->query("INSERT INTO ps_customization_field (id_product,type,required) SELECT id_product,0,0 FROM ps_product WHERE id_shop_default = 1 AND customizable = 1;");
$conn->query("INSERT INTO ps_customization_field (id_product,type,required) SELECT id_product,1,1 FROM ps_product WHERE id_shop_default = 1 AND customizable = 1;");
echo "Added uploadable files & customized field to each item!<br /><br />";
$conn->query("truncate table ps_customization_field_lang;");
$conn->query("INSERT INTO ps_customization_field_lang (id_customization_field, id_lang,id_shop,name) select id_customization_field,1,1,'Upload 1' from ps_customization_field WHERE type = 0;");
$conn->query("INSERT INTO ps_customization_field_lang (id_customization_field, id_lang,id_shop,name) select id_customization_field,1,1,'Field 1' from ps_customization_field WHERE type = 1;");
echo "Added appropriate labeling for each field, for each product!<br /><br />";
echo "<h2>Yay, We're done!</h2>";
$conn->close();
显然,这可以更新/更改,以满足任何人的要求。