magento / magento/community-features

Please make Models, ResourceModel and Collection _construct method abstract.

Open
#172 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Priority: P4
Dominant language
No language data
Stars
46
Forks
14
PR merge metrics
No merged PRs in 30d

Description

Every custom Model, ResourceModel and Collection that extends from the core abstract classes from Magento\Framework\Model\ ... has to implement the _construct() method in which to call the _init() method and set things like table_name and primary_key in the ResourceModel and so on.

That this is smelly code I'm sure that you are aware and I'm not judging God knows how much work you have going on.

But please enforce this by making the _construct() method abstract and leave a comment something like //call the init method a developer should not have to remember or memorize that every time he creates a Model(or any other entity related class) he has to implement some secret method or else things are not working.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the core abstract Model, ResourceModel, and Collection classes under Magento\Framework\Model and review how their subclasses currently implement _construct() and call _init(). The work is done when those base classes enforce the required implementation and existing model, resource-model, and collection initialization continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.