0
<block class="Magento\Store\Block\Switcher" name="store_language" as="store_language" template="Magento_Store::switch/languages.phtml">
<arguments>
<argument name="view_model" xsi:type="object">Magento\Store\ViewModel\SwitcherUrlProvider</argument>
</arguments>
</block>

I just want to call the above block via Static block (From Admin), but it gives an error due to ViewModel class.

I don't know how to pass view model argument when we call block via static block

Does anyone have any idea?

0

You cannot set object as arguments when using the Markup Notation in Magento2.

{{block class="Magento\Framework\View\Element\Template" view_model="Vendor\Example\ViewModel\Standard" name="Vendor_Example::view.phtml" }}

In view.phtml

If you execute echo $block->getViewModel() will return Vendor\Example\ViewModel\Standard as a string and not an object.

| improve this answer | |

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.