1

我有一个属性“衣服”,带有多选选项“裙子”、“裤子”、“货物”……

属性ID是说,

裙子 198 裤子 199 货物 200

我必须用属性裙子标记一系列产品,我这样做,

$collection->setClothes('198');
$collection->save();

现在我也想用属性 pant 标记同一个集合,

如果我使用,

$collection->setClothes('199');

它会覆盖,现在该产品仅标记为裤子,而不是裙子和裤子。

我需要帮助正确标记具有多个属性的产品(使用多选时)

另一种情况是,我有一个产品标签到裙子,我想从裙子上取消它的标签。

我已经尽力了。有人可以帮我解决这个问题。

4

1 回答 1

2

你试过$collection->setClothes(array('198','199'));吗?

要取消标记,您只需:

$tags = $collection->getClothes(); //let's say we have 5 tags.. 192, 193, 194, 199, 198.

$tagsToRemove = array('194','199');

$collection->setClothes(
    array_diff($tags, $tagsToRemove)
);
于 2013-08-09T06:01:20.343 回答