I am updating produts programmatically and it sometimes happens that an attribute for a product is not used anymore. In that case, the attribute value should of course be removed. However, I can not find a way to do that. The update works just fine, but values aren't getting removed from the model.
I have looked around a bit and it seemed that the following would be the solution:
$product->unsetData($attributeCode);
But this does not remove the value. The attribute code is correct and everything else works perfectly fine. I also checked and it does use the right store.
I have gotten suggestions on doing this directly through the database, but I'd rather do it on the model for safety.
Best Answer
I suggest making the attribute's value empty:
or:
or, as you have saved the product you need to save the product object:
This will take effect after the object is saved.