If I run $product->setDescription($text) with plain text and then save the object, it works as expected.
However, if $text contains HTML, it does not update the record.
Is there something I'm missing?
You can try to use like Magento natively uses like this:
$product->setDescription('Description with <b>html tag</b>');
Check the method like you get the description too.
If you want to save the HTML format product description. You need to follow this step.
Go to Magento admin panel -> Catalog -> Attribute -> Manage Attribute
Search "description" attribute_code , click on it.
find the option "Enable WYSIWYG" set it to "Yes" then save.
Now try to set $product->setDescription($text) it will save HTML Data.
I think the problem is not with the source code but with the CSV file format. While saving the CSV file, you have to choose the character set as UTF-8. Then it should be working. I tried and it works for me.
When I added
<![CDATA[...]]> to description, magento save this with HTML tags. I use Magento\Catalog\Model\ResourceModel\Product to fast save product.
$productResource = $this->_objectManager->create('Magento\Catalog\Model\ResourceModel\Product'); $product->setDescription($string_variable_with_meta_cdata); $productResource->saveAttribute($product, 'description');