Skip to content

How to add view model to existing phtml and block

Is there any possibility to add ViewModel to the existing block and PHTMl file? I’m trying to add ViewModel to the file below.

sales_email_order_renderers

Code:

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Creditmemo Items List" design_abstraction="custom">
    <body>
        <referenceBlock name="sales.email.order.renderers">
            <block class="MagentoSalesBlockOrderEmailItemsOrderDefaultOrder" name="sales.email.order.renderers.default" as="default" template="Test_Module::email/items/order/default.phtml"/>
        </referenceBlock>
    </body>
</page>

Thanks in advance