我等待答案太久,自己做,这里有一个解决方法:
我的修复方法是其他方式 - 只有添加 $item["category_reset"] == 1; 才能清除类别位置参数到产品参数。
:1280 sting(在当前 magmi 版本中)或在 magmi_productimportengine.php 中找到 public 函数 assignCategories($pid, $item)。
吃掉
$cce = $this->tablename("catalog_category_entity");
$ccpt = $this->tablename("catalog_category_product");
添加下一个代码:
$sql = "SELECT $ccpt.*
FROM $ccpt
JOIN $cce ON $cce.entity_id=$ccpt.category_id
WHERE product_id=?";
$currentPositions = $this->selectAll($sql,$pid);
然后更改类别重置:
if (!isset($item["category_reset"]) || $item["category_reset"] == 1)
{...}
到
if (isset($item["category_reset"]) && $item["category_reset"] == 1)
{
$sql = "DELETE $ccpt.*
FROM $ccpt
JOIN $cce ON $cce.entity_id=$ccpt.category_id
WHERE product_id=?";
$this->delete($sql, $pid);
$currentPositions = array();
}
在这个带有定位的更改块之后
foreach ($catids as $catdef)
{...}
到:
// find positive category assignments
if (is_array($currentPositions) && count($currentPositions)) {
foreach ($currentPositions as $currentPosition) {
$catPos[$currentPosition['category_id']] = $currentPosition['position'];
}
}
foreach ($catids as $catdef)
{
$a = explode("::", $catdef);
$catid = $a[0];
if (count($a) > 1 && $a[1] != 0) {
$catpos = $a[1];
}
else {
if (isset($catPos[$catid]) && $catPos[$catid] != 0) {
$catpos = $catPos[$catid];
}
else {
$catpos = "0";
}
}
$rel = getRelative($catid);
if ($rel == "-")
{
$ddata[] = $catid;
}
else
{
$cdata[$catid] = $catpos;
}
}
如果你不导入位置,你的当前位置将被保存。如果为 0,则保持为 0。
为了明确实际位置 - 将参数添加到产品项:
$item["category_reset"] == 1;
或者改回字符串:
if ($item["category_reset"] == 1)
{ ....}
到:
if (!isset($item["category_reset"]) || $item["category_reset"] == 1)
{...}