3

Is it a good practice in Magento CE 2.1 to put all code intelligence of a module in Blocks and leave the Controller almost empty ?

1

According to this StackOverflow topic,

Block are responsible for rendering content (everything from frontend, backend, emails, and more). If content is being displayed somewhere chances are it is a block.

controllers are responsible for processing all requests made via a url. If you hit the url http://www.example.com/catalog/product/view/id/9/ you hit the catalog module in the controllers/ProductController.php and inside of that the viewAction() method. If you hit a URL in Magento the request passes through one or more controllers.

Also, this topic can help you understand the concept of a Block: Why does Magento need blocks?

| 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.