I'm currently rewriting a layout file:
<referenceBlock name="checkout.cart.totals> <!-- some stuff --> </referenceBlock>
Is it possible to set the block class here?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
As of 2.2.* the short answer: No
What you can do instead is to remove and then add new block with your specific class:
<referenceContainer name="content"> <!-- Remove old block --> <referenceBlock name="checkout.cart.totals" remove="true"/> <!-- Add new block --> <block name="checkout.cart.totals" class="Vendor\Module\Block\Checkout\Cart\Totals"> <!-- some stuff --> </block> </referenceContainer>
The other way is to extend Vendor Block class for your needs, you can read more about it here: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/module-development.html