0

First I overwrite checkout_cart_index.xml in my module like below

app/code/Custom/Module/view/frontend/layout/checkout_cart_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock class="Magento\Checkout\Block\Cart" name="checkout.cart.form">
            <block class="Magento\Framework\View\Element\RendererList" name="checkout.cart.item.renderers.override" as="renderer.list.custom"/>
            <arguments>
                <argument name="renderer_list_name" xsi:type="string">checkout.cart.item.renderers.override</argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Then I overwrite

checkout_cart_item_renderers.xml

in my module like below

<?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>
<referenceBlock name="checkout.cart.item.renderers.override">
            <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="Custom_Module::cart/item/default.phtml" />              
            <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="Custom_Module::cart/item/default.phtml" />  
        </referenceBlock>
    </body>
</page>

Then I overwrite default.phtml file under below path

app/code/Custom/Module/view/frontend/templates/cart/item/default.phtml

After doing this I run below Command also:

php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento cache:flush

I am getting below error in checkout page:- `

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'referenceBlock', attribute 'class': The attribute 'class' is not allowed.
Line: 1478
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'referenceBlock', attribute 'class': The attribute 'class' is not allowed.
Line: 1478
#0 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Config/Dom.php(115): Magento\Framework\Config\Dom->_initDom('<layout xmlns:x...')
#1 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(111): Magento\Framework\Config\Dom->__construct('<layout xmlns:x...', Object(Magento\Framework\App\Arguments\ValidationState), Array, NULL, '/home/193246.cl...', '%message%\nLine:...')
#2 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
#3 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...', Array)
#4 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Config/DomFactory.php(42): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Framewo...', Array)
#5 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Model/Layout/Update/Validator.php(141): Magento\Framework\Config\DomFactory->createDom(Array)
#6 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Model/Layout/Merge.php(461): Magento\Framework\View\Model\Layout\Update\Validator->isValid('<layout xmlns:x...', 'layout_merged', false)
#7 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Model/Layout/Merge.php(442): Magento\Framework\View\Model\Layout\Merge->_validateMergedLayout('LAYOUT_frontend...', '<body>\n   <refe...')
#8 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout/Builder.php(86): Magento\Framework\View\Model\Layout\Merge->load()
#9 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Layout/Builder.php(63): Magento\Framework\View\Layout\Builder->loadLayoutUpdates()
#10 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Page/Config.php(197): Magento\Framework\View\Layout\Builder->build()
#11 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/View/Page/Config.php(217): Magento\Framework\View\Page\Config->build()
#12 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/module-checkout/Controller/Cart/Index.php(55): Magento\Framework\View\Page\Config->getTitle()
#13 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Checkout\Controller\Cart\Index->execute()
#14 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Controller\Cart\Index\Interceptor->___callParent('execute', Array)
#15 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Controller\Cart\Index\Interceptor->Magento\Framework\Interception\{closure}()
#16 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/generated/code/Magento/Checkout/Controller/Cart/Index/Interceptor.php(26): Magento\Checkout\Controller\Cart\Index\Interceptor->___callPlugins('execute', Array, Array)
#17 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/App/Action/Action.php(107): Magento\Checkout\Controller\Cart\Index\Interceptor->execute()
#18 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#19 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Controller\Cart\Index\Interceptor->___callParent('dispatch', Array)
#20 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Controller\Cart\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#21 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/generated/code/Magento/Checkout/Controller/Cart/Index/Interceptor.php(39): Magento\Checkout\Controller\Cart\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#22 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/App/FrontController.php(55): Magento\Checkout\Controller\Cart\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#23 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#24 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#25 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#26 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#27 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#28 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#29 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#30 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#31 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#32 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http->launch()
#33 /home/193246.cloudwaysapps.com/zqesqtynyy/public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#34 {main}
  • If your purpose is to set custom template file, then you can used settemplate method of block. – Dhiren Vasoya Mar 5 at 14:10
  • @DhirenVasoya I used plugin also, but I am not able to overwrite successfully. – Nilava Chakraborty Mar 5 at 14:22
  • @DhirenVasoya I followed below link but still no luck rakeshjesadiya.com/… – Nilava Chakraborty Mar 5 at 14:25
1

You are adding the same class twice

checkout_cart_item_renderers.xml

<?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>
<referenceBlock name="checkout.cart.item.renderers.override">
            <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="Custom_Module::cart/item/default.phtml" />              
            <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="Custom_Module::cart/item/default.phtml" />  
        </referenceBlock>
    </body>
</page>

Remove it

<block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="Custom_Module::cart/item/default.phtml" />

Will be something like this

<?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>
        <referenceBlock name="checkout.cart.item.renderers.override">
            <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="Custom_Module::cart/item/default.phtml">
            </block>
        </referenceBlock>
    </body>
</page>

Run commands

php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento cache:clean
php bin/magento cache:flush

Test it.

Check Rakesh override for more info: link

  • after deleting the line also getting same error – Nilava Chakraborty Mar 5 at 14:13
  • do a rm -rf generated/* rm -rf pub/static/* , run the above commands – Ylgen Guxholli Mar 5 at 14:16
  • Yes, I run below command also:- rm -rf generated/ , rm -rf pub/static/frontend/ , rm -rf var/ but no luck – Nilava Chakraborty Mar 5 at 14:19
  • correct the tags also , updated my answer – Ylgen Guxholli Mar 5 at 14:33
  • Not understand which tag are you talking about? – Nilava Chakraborty Mar 5 at 14:47

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.