Magento 2.2.0-rc30 (in this case, but been like this on previous rc's)
Nothing special
Place the following code in your themes default.xml layout file
<attribute name="itemtype" remove="true"/>
<attribute name="itemscope" remove="true"/>
The itemtype and itemscope attributes are removed from the product html output. Modules that implement their own Rich Snippets use this code to remove the inbuilt rich snippets.
When viewing any product page.
Exception #0 (MagentoFrameworkConfigDomValidationException): Element 'attribute', attribute 'remove': The attribute 'remove' is not allowed.
This works as excpected under 2.1.8. Is this an intentional change in 2.2?
@gwharton, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.2.0
Ubuntu 16.04.3 LTS up to date
Magento 2.2.0-rc30 installed with composer
setup run with all default options
On Admin Backend
- Catalog -> Products -> Add Product
- Name -> Test
- Price -> 1.00
- Quantity -> 1
- Category -> Default Category
- Save and Close
Upload GW/frontend theme to app/design/frontend
Theme source can be downloaded from here or create your own theme with the Magento_Theme/layout/default.xml file as follows.
<?xml version="1.0"?>
<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" remove="true"/>
<attribute name="itemscope" remove="true"/>
</body>
</page>
On Admin Backend
Content -> Configuration -> Global -> Edit
- Change Theme to "Magento 2 GW Frontend Theme"
- (Or your own theme name if you created your own)
- Save Configuration
Using Browser go to frontend
- http://<frontend>/test.html
- View Source and check that the <body> tag does not include itemtype and itemscope.
- (Expected behavior of theme)
On Command Line
- php bin/magento deploy:mode:set developer
- rm -rf pub/static/*
- rm -rf var/view_preprocessed/*
- rm -rf var/generation/*
- rm -rf var/cache/*
- rm -rf var/di/*
- rm -rf var/page_cache/*
- php bin/magento setup:upgrade
- php bin/magento setup:di:compile
- php bin/magento cache:clean
Using Browser go to frontend
- http://<frontend>/test.html
- Verify that you now receive the error
- Exception #0 (Magento\Framework\Config\Dom\ValidationException):
- Element 'attribute', attribute 'remove': The attribute 'remove' is not allowed.
On Command Line
- php bin/magento deploy:mode:set production
Using Browser go to frontend
- http://<frontend>/test.html
- View Source and check that the <body> tag does not include itemtype and itemscope
- (Expected behavior of theme)
On Command Line
- php bin/magento deploy:mode:set developer
- rm -rf pub/static/*
- rm -rf var/view_preprocessed/*
- rm -rf var/generation/*
- rm -rf var/cache/*
- rm -rf var/di/*
- rm -rf var/page_cache/*
- php bin/magento setup:upgrade
- php bin/magento setup:di:compile
- php bin/magento cache:clean
Using Browser go to frontend
- http://<frontend>/test.html
- Verify that you now receive the error
- Exception #0 (Magento\Framework\Config\Dom\ValidationException):
- Element 'attribute', attribute 'remove': The attribute 'remove' is not allowed.
The expected behavior is seen in production mode, and the erroneous behavior is seen in developer mode.
@magento-engcom-team I am unable to reopen this issue, but I have added more detailed steps to reproduce above. Could you assess and reopen if it can be reproduced at your end.
@gwharton, thank you for your report.
We've created internal ticket(s) MAGETWO-81760 to track progress on the issue.
Any Update? Facing the same issue after upgrade from 2.1.7 to 2.2 .
So, I picked out the xsd's from Magento 2.1 (and magento 2.0) and validated the default.xml from the above example against them and it fails to validate in the same way.
The only thing I can imagine is going on is in 2.1 the xsd validation was not being carried out properly and it was allowing the remove attributes as above when it shouldn't have.
Now that the xsd validation is working properly in 2.2, it is failing to validate, and rightly so.
As a temporary workaround I have modified the framework xsd body.xsd to include the remove attribute as optional. A hack to core code, I know, but its a workaround.
The only thing I can imagine is going on is in 2.1 the xsd validation was not being carried out properly and it was allowing the remove attributes as above when it shouldn't have.
Exactly, we figured it out in some issue here right after 2.2 release. No such info in release notes though.
@gwharton You can still do this from xml, by changing the attribute value:
<attribute name="itemtype" value="" />
<attribute name="itemscope" value="" />
Same thing for arguments:
<argument name="whatever name" xsi:type="string"></argument>
Thanks @mihaifaget
I hadn't realised you can remove the item by setting its value to "".
remove is not allowed in <attribute> in the layout file. v2.2.5
@mihaifaget 's comment works, thanks mate.
Most helpful comment
@gwharton You can still do this from xml, by changing the attribute value:
<attribute name="itemtype" value="" /><attribute name="itemscope" value="" />Same thing for arguments:
<argument name="whatever name" xsi:type="string"></argument>