Skip to content

Improve View Models documentation with best practices and clarification - #423

Open
mohaelmrabet wants to merge 4 commits into
AdobeDocs:mainfrom
mohaelmrabet:patch-1
Open

mohaelmrabet wants to merge 4 commits into
AdobeDocs:mainfrom
mohaelmrabet:patch-1

Conversation

@mohaelmrabet

@mohaelmrabet mohaelmrabet commented Nov 17, 2025

Copy link
Copy Markdown

I improved the View Models documentation to make it easier to understand and more useful for developers.

What I added:

  • clearer explanation of blocks vs. view models
  • simple notes about SRP and why view models help keep code clean
  • tips on reusability and using multiple view models
  • a short section about cache behavior
  • naming guidelines
  • a small checklist for creating a view model

Nothing technical was changed—just clearer wording and extra best practices to help developers.

Purpose of this pull request

This pull request (PR) ...

Affected pages

I improved the View Models documentation to make it easier to understand and more useful for developers.

What I added:
- clearer explanation of blocks vs. view models
- simple notes about SRP and why view models help keep code clean
- tips on reusability and using multiple view models
- a short section about cache behavior
- naming guidelines
- a small checklist for creating a view model

Nothing technical was changed—just clearer wording and extra best practices to help developers.
@github-project-automation github-project-automation Bot moved this from 📋 Needs Review to 👍 Approved in Commerce - Pull Requests May 15, 2026
@meker12 meker12 self-assigned this May 15, 2026
@dshevtsov dshevtsov closed this Jul 13, 2026
@github-project-automation github-project-automation Bot moved this from 👍 Approved to 🏁 Done in Commerce - Pull Requests Jul 13, 2026
@dshevtsov dshevtsov reopened this Jul 13, 2026
@github-project-automation github-project-automation Bot moved this from 🏁 Done to 🧑‍💻 In Progress in Commerce - Pull Requests Jul 13, 2026
<argument name="utility_view_model" xsi:type="object">Vendor\Module\ViewModel\Utility</argument>
</arguments>
```
Retrieve them in the template using $block->getViewModel() or custom accessors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Retrieve them in the template using $block->getViewModel() or custom accessors.
Retrieve them in the template using `$block->getViewModel()` or custom accessors.

@@ -72,8 +72,9 @@ $viewModel = $block->getViewModel();
```

## Examples

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Examples
## Examples

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🛠 Changes Requested

Development

Successfully merging this pull request may close these issues.

3 participants