Question

enter image description here

I have installed an extension which puts Rich Cards on my product pages, however the default Magento structured data code for rich snippets is still present. How can I remove this from product pages?

Was it helpful?

Solution

This helps me to remove Magento default product schema by following steps.

1. Remove product schema from body. Add this to catalog_product_view.xml under your theme.

<body>
    <attribute name="itemtype" remove="true"/>
    <attribute name="itemscope" remove="true"/>
</body>

2. Remove aggregateRating

Copy this to your theme

vendor/magento/module-review/view/frontend/templates/helper/summary.phtml

remove

itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"

3. Remove Review

Copy this to your theme

vendor/magento/module-review/view/frontend/templates/product/view/list.phtml

Remove

itemscope itemprop="review" itemtype="http://schema.org/Review"

Note: missing #2 and #3 will receive an error similar to below in validation due to action #1

“The review has no reviewed item specified.”

OTHER TIPS

When I added remove='true' to these attributes - I got the following error:

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'attribute', attribute 'remove': The attribute 'remove' is not allowed.

To get these properties to disappear, I changed them to this instead:

<attribute name="itemtype" value="" />
<attribute name="itemscope" value="" />

Reference for the Solution:

https://github.com/magento/magento2/issues/10889

You can remove the default schema.org from catalog_product_view.xml file. Add below the line of code:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>            
    <attribute name="itemtype" value=""/>
    <attribute name="itemscope" value=""/>
</body>
</page>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top