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.

  • Okay, that does work, so Magento must not like the markup in the description. I'm migrating over 3,000 products, I hope there's an easy solution to this! – Geat Apr 14 '17 at 0:16

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.

  • WYSIWYG is indeed enabled, and I can save simple markup. But when I try to import data from an old site, it fails. There must be something in the string that it doesn't like. – Geat Apr 17 '17 at 15:37

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');
$productResource->saveAttribute($product, 'description');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.