Reputation: 13
I have an attribute "Clothes" with multiselect options "Skirt","Pant","Cargos"...
The attribute id's are say,
skirt-198 pant-199 cargos-200
I have to tag a collection of products with attribute skirt, i do it this way,
$collection->setClothes('198');
$collection->save();
Now i want to tag the same collection with the attribute pant as well,
if i use,
$collection->setClothes('199');
it overwrites and now the product is tagged only to pants and not to both skirts and pants.
I need help in rightly tagging a product with multiple attributes(when multiselect is used)
And another case is where, I have a product tagged to skirts and I want to untag it from skirts.
I have tried my best. Can someone pls help me solve this.
Upvotes: 1
Views: 390
Reputation: 4486
Have you tried $collection->setClothes(array('198','199'));
?
and to untag, you simply have to:
$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)
);
Upvotes: 2