{"id":"f77c5cfa-64ad-4b17-a189-f5a572118579","shortId":"c3ycWV","kind":"skill","title":"magento-model-developer","tagline":"Designs and implements data layer architecture for Magento 2. Use when creating data models, designing database schemas, implementing repositories, or working with EAV/flat table structures. Masters entity design, repository patterns, collections, and database optimization.","description":"# Magento 2 Model Developer\n\nExpert specialist in designing and implementing robust data layer architectures, creating efficient, scalable data models that serve as the foundation for enterprise e-commerce applications.\n\n## When to Use\n\n- Creating data models and entities\n- Designing database schemas\n- Implementing repository patterns\n- Working with EAV or flat table structures\n- Optimizing database queries\n- Building data collections\n\n## Data Architecture\n\n- **Model Design**: Create efficient entity models following Magento patterns\n- **EAV vs Flat Tables**: Choose optimal data storage strategies for different scenarios\n- **Repository Pattern**: Implement clean data access layers and service contracts\n- **Collection Optimization**: Build high-performance data collections and queries\n- **Database Schema Design**: Design normalized, efficient database structures\n\n## Model Development Process\n\n### 1. Data Requirements Analysis\n- **Business Requirements**: Understand entity relationships and business rules\n- **Performance Requirements**: Plan for expected data volume and query patterns\n- **Storage Strategy**: Choose between EAV and flat table storage approaches\n- **Relationship Mapping**: Design entity relationships and dependencies\n- **Scalability Planning**: Plan for future growth and data expansion\n\n### 2. Database Schema Design\n- **Table Structure**: Design efficient table structures and relationships\n- **Data Types**: Choose appropriate data types for optimal storage and performance\n- **Indexing Strategy**: Plan indexes for search, sorting, and filtering operations\n- **Constraints**: Implement proper database constraints and validation\n- **Migration Scripts**: Create database migration and upgrade scripts\n\n### 3. Model Implementation\n- **Entity Classes**: Implement model classes with proper validation and logic\n- **Resource Models**: Create efficient database interaction layers\n- **Collection Development**: Build optimized collection classes with filtering\n- **Repository Implementation**: Create repository classes following service contracts\n- **Factory Classes**: Implement proper object factories and builders\n\n### 4. Integration & Testing\n- **API Integration**: Integrate models with REST and GraphQL APIs\n- **Cache Integration**: Implement proper caching strategies for model data\n- **Performance Testing**: Validate model performance under expected load\n- **Data Validation**: Test data integrity and validation rules\n- **Migration Testing**: Test database migrations and data consistency\n\n## Model Types\n\n### Entity Model\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace Vendor\\Module\\Model;\n\nuse Magento\\Framework\\Model\\AbstractModel;\nuse Vendor\\Module\\Model\\ResourceModel\\Entity as ResourceModel;\n\nclass Entity extends AbstractModel\n{\n    protected function _construct(): void\n    {\n        $this->_init(ResourceModel::class);\n    }\n}\n```\n\n### Resource Model\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace Vendor\\Module\\Model\\ResourceModel;\n\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb;\n\nclass Entity extends AbstractDb\n{\n    protected function _construct(): void\n    {\n        $this->_init('vendor_module_entity', 'entity_id');\n    }\n}\n```\n\n### Collection\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace Vendor\\Module\\Model\\ResourceModel\\Entity;\n\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\Collection\\AbstractCollection;\nuse Vendor\\Module\\Model\\Entity;\nuse Vendor\\Module\\Model\\ResourceModel\\Entity as ResourceModel;\n\nclass Collection extends AbstractCollection\n{\n    protected function _construct(): void\n    {\n        $this->_init(Entity::class, ResourceModel::class);\n    }\n}\n```\n\n### Repository Implementation\n```php\n<?php\n\ndeclare(strict_types=1);\n\nnamespace Vendor\\Module\\Model;\n\nuse Vendor\\Module\\Api\\Data\\EntityInterface;\nuse Vendor\\Module\\Api\\EntityRepositoryInterface;\nuse Vendor\\Module\\Model\\ResourceModel\\Entity as ResourceModel;\nuse Magento\\Framework\\Exception\\NoSuchEntityException;\n\nclass EntityRepository implements EntityRepositoryInterface\n{\n    /**\n     * @param ResourceModel $resource\n     */\n    public function __construct(\n        private readonly ResourceModel $resource\n    ) {\n    }\n\n    /**\n     * @param int $id\n     * @return EntityInterface\n     * @throws NoSuchEntityException\n     */\n    public function getById(int $id): EntityInterface\n    {\n        $entity = $this->resource->load($id);\n        if (!$entity->getId()) {\n            throw new NoSuchEntityException(__('Entity with id \"%1\" does not exist.', $id));\n        }\n        return $entity;\n    }\n}\n```\n\n## Database Schema (db_schema.xml)\n\n```xml\n<?xml version=\"1.0\"?>\n<schema xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n        xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd\">\n    <table name=\"vendor_module_entity\" resource=\"default\" engine=\"innodb\" comment=\"Entity Table\">\n        <column xsi:type=\"int\" name=\"entity_id\" unsigned=\"true\" nullable=\"false\" identity=\"true\" comment=\"Entity ID\"/>\n        <column xsi:type=\"varchar\" name=\"name\" length=\"255\" nullable=\"false\" comment=\"Name\"/>\n        <column xsi:type=\"timestamp\" name=\"created_at\" nullable=\"false\" default=\"CURRENT_TIMESTAMP\" comment=\"Created At\"/>\n        <constraint xsi:type=\"primary\" referenceId=\"PRIMARY\">\n            <column name=\"entity_id\"/>\n        </constraint>\n        <index referenceId=\"VENDOR_MODULE_ENTITY_NAME\" indexType=\"btree\">\n            <column name=\"name\"/>\n        </index>\n    </table>\n</schema>\n```\n\n## EAV vs Flat Tables\n\n### EAV (Entity-Attribute-Value)\n- Use for entities with many optional attributes\n- Flexible attribute management\n- Higher query complexity\n- Use for products, customers, categories\n\n### Flat Tables\n- Use for entities with fixed attributes\n- Better query performance\n- Simpler data model\n- Use for orders, quotes, simple entities\n\n## Best Practices\n\n### Performance\n- **Query Optimization**: Optimize database queries and eliminate N+1 problems\n- **Index Strategy**: Design efficient database indexing\n- **Collection Optimization**: Use proper filters and pagination\n- **Lazy Loading**: Implement lazy loading for expensive operations\n- **Caching**: Cache frequently accessed data\n\n### Data Integrity\n- **Validation**: Implement comprehensive data validation\n- **Constraints**: Use database constraints where appropriate\n- **Transactions**: Use transactions for multi-step operations\n- **Referential Integrity**: Maintain proper foreign key relationships\n- **Data Consistency**: Ensure data consistency across operations\n\n### Code Quality\n- **Service Contracts**: Use interfaces for repositories\n- **Type Hints**: Use proper type hints throughout\n- **Error Handling**: Comprehensive error handling\n- **Documentation**: Document data models and relationships\n- **Testing**: Write tests for models and repositories\n\n## References\n\n- [Adobe Commerce Models](https://developer.adobe.com/commerce/php/development/components/model/)\n- [Repository Pattern](https://developer.adobe.com/commerce/php/development/components/repository-pattern/)\n- [Database Schema](https://developer.adobe.com/commerce/php/development/components/declarative-schema/)\n\nFocus on creating efficient, scalable data models that serve as a solid foundation for enterprise applications.","tags":["magento","model","developer","magento2","agent","skills","maxnorm","agent-skills"],"capabilities":["skill","source-maxnorm","skill-magento-model-developer","topic-agent-skills","topic-magento2"],"categories":["magento2-agent-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/maxnorm/magento2-agent-skills/magento-model-developer","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add maxnorm/magento2-agent-skills","source_repo":"https://github.com/maxnorm/magento2-agent-skills","install_from":"skills.sh"}},"qualityScore":"0.454","qualityRationale":"deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 9 github stars · SKILL.md body (7,278 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:08:49.886Z","embedding":null,"createdAt":"2026-05-07T20:44:03.263Z","updatedAt":"2026-05-18T19:08:49.886Z","lastSeenAt":"2026-05-18T19:08:49.886Z","tsv":"'+1':603 '/commerce/php/development/components/declarative-schema/)':715 '/commerce/php/development/components/model/)':705 '/commerce/php/development/components/repository-pattern/)':710 '1':150,344,381,415,464,534 '2':13,40,198 '3':246 '4':290 'abstractcollect':429,446 'abstractdb':393,397 'abstractmodel':353,365 'access':124,629 'across':664 'adob':700 'analysi':153 'api':293,301,472,478 'applic':68,731 'approach':181 'appropri':213,643 'architectur':10,52,97 'attribut':552,560,562,579 'best':592 'better':580 'build':93,131,268 'builder':289 'busi':154,160 'cach':302,306,626,627 'categori':571 'choos':111,174,212 'class':250,253,271,278,283,362,373,394,443,454,456,493 'clean':122 'code':666 'collect':35,95,129,136,266,270,409,428,444,611 'commerc':67,701 'complex':566 'comprehens':635,683 'consist':334,660,663 'constraint':231,235,638,641 'construct':368,400,449,502 'contract':128,281,669 'creat':16,53,72,100,240,261,276,718 'custom':570 'data':8,17,50,56,73,94,96,113,123,135,151,167,196,210,214,310,319,322,333,473,584,630,631,636,659,662,688,721 'databas':20,37,78,91,139,145,199,234,241,263,330,541,598,609,640,711 'db':392,427 'db_schema.xml':543 'declar':341,378,412,461 'depend':188 'design':5,19,32,46,77,99,141,142,184,201,204,607 'develop':4,42,148,267 'developer.adobe.com':704,709,714 'developer.adobe.com/commerce/php/development/components/declarative-schema/)':713 'developer.adobe.com/commerce/php/development/components/model/)':703 'developer.adobe.com/commerce/php/development/components/repository-pattern/)':708 'differ':117 'document':686,687 'e':66 'e-commerc':65 'eav':85,107,176,545,549 'eav/flat':27 'effici':54,101,144,205,262,608,719 'elimin':601 'ensur':661 'enterpris':64,730 'entiti':31,76,102,157,185,249,337,359,363,395,406,407,421,434,440,453,485,520,526,531,540,551,556,576,591 'entity-attribute-valu':550 'entityinterfac':474,511,519 'entityrepositori':494 'entityrepositoryinterfac':479,496 'error':681,684 'except':491 'exist':537 'expans':197 'expect':166,317 'expens':624 'expert':43 'extend':364,396,445 'factori':282,287 'filter':229,273,615 'fix':578 'flat':87,109,178,547,572 'flexibl':561 'focus':716 'follow':104,279 'foreign':656 'foundat':62,728 'framework':351,389,424,490 'frequent':628 'function':367,399,448,501,515 'futur':193 'getbyid':516 'getid':527 'graphql':300 'growth':194 'handl':682,685 'high':133 'high-perform':132 'higher':564 'hint':675,679 'id':408,509,518,524,533,538 'implement':7,22,48,80,121,232,248,251,275,284,304,458,495,620,634 'index':221,224,605,610 'init':371,403,452 'int':508,517 'integr':291,294,295,303,323,632,653 'interact':264 'interfac':671 'key':657 'layer':9,51,125,265 'lazi':618,621 'load':318,523,619,622 'logic':258 'magento':2,12,39,105,350,388,423,489 'magento-model-develop':1 'maintain':654 'manag':563 'mani':558 'map':183 'master':30 'migrat':238,242,327,331 'model':3,18,41,57,74,98,103,147,247,252,260,296,309,314,335,338,348,352,357,375,385,390,419,425,433,438,468,483,585,689,696,702,722 'modul':347,356,384,405,418,432,437,467,471,477,482 'multi':649 'multi-step':648 'n':602 'namespac':345,382,416,465 'new':529 'normal':143 'nosuchentityexcept':492,513,530 'object':286 'oper':230,625,651,665 'optim':38,90,112,130,217,269,596,597,612 'option':559 'order':588 'pagin':617 'param':497,507 'pattern':34,82,106,120,171,707 'perform':134,162,220,311,315,582,594 'php':339,340,376,377,410,411,459,460 'plan':164,190,191,223 'practic':593 'privat':503 'problem':604 'process':149 'product':569 'proper':233,255,285,305,614,655,677 'protect':366,398,447 'public':500,514 'qualiti':667 'queri':92,138,170,565,581,595,599 'quot':589 'readon':504 'refer':699 'referenti':652 'relationship':158,182,186,209,658,691 'repositori':23,33,81,119,274,277,457,673,698,706 'requir':152,155,163 'resourc':259,374,499,506,522 'resourcemodel':358,361,372,386,391,420,426,439,442,455,484,487,498,505 'rest':298 'return':510,539 'robust':49 'rule':161,326 'scalabl':55,189,720 'scenario':118 'schema':21,79,140,200,542,712 'script':239,245 'search':226 'serv':59,724 'servic':127,280,668 'simpl':590 'simpler':583 'skill' 'skill-magento-model-developer' 'solid':727 'sort':227 'source-maxnorm' 'specialist':44 'step':650 'storag':114,172,180,218 'strategi':115,173,222,307,606 'strict':342,379,413,462 'structur':29,89,146,203,207 'tabl':28,88,110,179,202,206,548,573 'test':292,312,321,328,329,692,694 'throughout':680 'throw':512,528 'topic-agent-skills' 'topic-magento2' 'transact':644,646 'type':211,215,336,343,380,414,463,674,678 'understand':156 'upgrad':244 'use':14,71,349,354,387,422,430,435,469,475,480,488,554,567,574,586,613,639,645,670,676 'valid':237,256,313,320,325,633,637 'valu':553 'vendor':346,355,383,404,417,431,436,466,470,476,481 'void':369,401,450 'volum':168 'vs':108,546 'work':25,83 'write':693 'xml':544","prices":[{"id":"70ca6651-1338-43ce-898b-fe80fe4ccf89","listingId":"f77c5cfa-64ad-4b17-a189-f5a572118579","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"maxnorm","category":"magento2-agent-skills","install_from":"skills.sh"},"createdAt":"2026-05-07T20:44:03.263Z"}],"sources":[{"listingId":"f77c5cfa-64ad-4b17-a189-f5a572118579","source":"github","sourceId":"maxnorm/magento2-agent-skills/magento-model-developer","sourceUrl":"https://github.com/maxnorm/magento2-agent-skills/tree/main/skills/magento-model-developer","isPrimary":false,"firstSeenAt":"2026-05-18T13:14:29.331Z","lastSeenAt":"2026-05-18T19:08:49.886Z"},{"listingId":"f77c5cfa-64ad-4b17-a189-f5a572118579","source":"skills_sh","sourceId":"maxnorm/magento2-agent-skills/magento-model-developer","sourceUrl":"https://skills.sh/maxnorm/magento2-agent-skills/magento-model-developer","isPrimary":true,"firstSeenAt":"2026-05-07T20:44:03.263Z","lastSeenAt":"2026-05-07T22:42:35.221Z"}],"details":{"listingId":"f77c5cfa-64ad-4b17-a189-f5a572118579","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"maxnorm","slug":"magento-model-developer","github":{"repo":"maxnorm/magento2-agent-skills","stars":9,"topics":["agent-skills","magento2"],"license":"mit","html_url":"https://github.com/maxnorm/magento2-agent-skills","pushed_at":"2026-01-24T16:45:35Z","description":"A collection of specialized agent skills for Magento 2 development, designed to provide domain expertise across all aspects of Magento/Adobe Commerce development workflows. ","skill_md_sha":"15fc8e5130e95e5696e661744b8301520b099639","skill_md_path":"skills/magento-model-developer/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/maxnorm/magento2-agent-skills/tree/main/skills/magento-model-developer"},"layout":"multi","source":"github","category":"magento2-agent-skills","frontmatter":{"name":"magento-model-developer","description":"Designs and implements data layer architecture for Magento 2. Use when creating data models, designing database schemas, implementing repositories, or working with EAV/flat table structures. Masters entity design, repository patterns, collections, and database optimization."},"skills_sh_url":"https://skills.sh/maxnorm/magento2-agent-skills/magento-model-developer"},"updatedAt":"2026-05-18T19:08:49.886Z"}}