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?

Amrit Pal Singh
1,6381 gold badge17 silver badges36 bronze badges
asked Sep 4, 2019 at 13:43

1 Answer 1

1

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.

answered Dec 26, 2019 at 12:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.