I am facing the error in Magento Localhost which is
Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid XML in file /var/www/html/magento/app/code/Mb/Customizations/etc/frontend/events.xml: Element 'event', attribute 'cachable': The attribute 'cachable' is not allowed. Line: 9
In the image you can see the error
So after That I tried to remove cacheable from the core class
magento/app/code/Mb/Customizations/etc/frontend/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="layout_generate_blocks_after">
<observer name="cust_productCanonical" instance="Mb\Customizations\Observer\ProductCanonical"/>
</event>
<event name="controller_action_predispatch_checkout_index_index" cachable="false">
<observer name="checkcout_page_pre" instance="Mb\Customizations\Observer\Preloadtab" />
</event>
<event name="controller_action_postdispatch_checkout_index_index" cachable="false">
<observer name="checkcout_page_post" instance="Mb\Customizations\Observer\Loadtab" />
</event>
</config>
but after removing the casheable
from the above xml
file it gives me some else error
1 exception(s): Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid XML in file /var/www/html/magento/app/code/TM/Crm/etc/frontend/events.xml: Element 'config': Missing child element(s). Expected is ( event ). Line: 2
magento/app/code/TM/Crm/etc/frontend/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<!-- <event name="checkout_onepage_controller_success_action">
<observer name="tm_crm_checkout_onepage_controller_success_action" instance="TM\Crm\Observer\Crm" />
</event> -->
</config>
So how can I remove this error and what is the problem in the above xml
file. Thanks
cachable="false"
should only be used for blocks not for events. here is the full docs from magento devdocs.magento.com/guides/v2.2/extension-dev-guide/cache/…cachable
then it give me another error1 exception(s): Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid XML in file /var/www/html/magento/app/code/TM/Crm/etc/frontend/events.xml: Element 'config': Missing child element(s). Expected is ( event ). Line: 2
magento/app/code/TM/Crm/etc/frontend/events.xml