Magento 2 does not strip the HTML tags while using the current product's description as the current HTML page's meta description (if the product does not have a dedicated meta description) (and my fix)

html-head
bug-fix
page-rendering
html-meta

(Dmitry Fedyuk) #1

The problem line is:

To fix the issue replace it with the new one:

$this->pageConfig->setDescription($this->string->substr(strip_tags($product->getDescription()), 0, 255));

How is Magento\Framework\View\Page\Config\Reader\Head::setMetadata() implemented and used?
How to add some HTML <meta> tags to a page via a layout.xml file?
How is Magento\Framework\View\Page\Config::setMetadata() implemented and used?
How is Magento\Framework\View\Page\Config\Generator\Head::processMetadata() implemented and used?
(Mike E) #2

This doesnt seem to be working on 2.0.2, its giving me a 500 server error. Any ideas?


(Dmitry Fedyuk) #3

You should learn how to diagnose the “50x” errors: it is a very basic skill for a PHP developer, and it is not related to the particular problem: How to diagnose Magento 2 errors


(Mike E) #4

im not a php developer… Just a guy trying to fix his site lol. I have the problem described here. And when I apply the fix you posted it gives a 500 error. I found my entire directory structure different than your example. Maybe because it is 2.0.2? Found in following location

/html/vendor/magento/module-catalog/Block/Product/view.php

Im not looking for handouts man, if ya can help me out ill send ya a few bucks.

Thanks
Mike


(Dmitry Fedyuk) #5

I have no “few bucks” support plan, but I recommend to implement Advices 2 and 3 from the instruction I linked in the previous message. It will help you to get the actual error message instead of a generic 500 code.


(Rob Gambino) #6

Thank you! worked like a charm!


(Dmitry Fedyuk) #7

See also: