Questions tagged [viewmodel]

The tag has no usage guidance.

7 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
2answers
44 views

The correct implementation of the output of subcategories in the main category

i want to display subcategories in the root category, i found this way that works for me. app/design/frontend/[Vendor]/[theme]/Magento_Catalog/templates/category/products.phtml <?php $category =...
2
votes
4answers
501 views

Can I and should I call Block methods from its' View Model?

I have a template and should write some logic. I have made a view model and I'm calling it from a template. Should I call block methods from the view model? And if so, how can I do it?
1
vote
1answer
17 views

Magento 2 Paginate custom collection using ViewModel

Magento 2 encourages the usage of view models instead of filling the blocks with business logic. A view model is an abstraction of the view exposing public properties and commands. It allows ...
1
vote
0answers
34 views

Editing breadcrumbs ViewModel method

I am trying to override a method from /vendor/magento/module-catalog/ViewModel/Product/Breadcrumbs.php I get an error Type Error occurred when creating object: Piranha\TagRemover\ViewModel\Product\...
0
votes
0answers
28 views

Getting information to an admin view page - block, viewmodel, both, etc

Old time Drupal guy here struggling with how to get data to the presentation layer. I have created ui listing and form components to list and edit records but there seems to be a gap in a process to ...
0
votes
0answers
14 views

how to pass view model class argument when call block from static block

<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="...
0
votes
2answers
773 views

Knockout.js What is the correct way to reference $parent on js file?

I am new on Knockout.js, especially on how to use it in the Magento way. I create a custom ViewModel with a js file called storepickup-select.js and an HTML template called storepickup-select.html. ...