# Magento Model Developer

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

- **Type:** Skill
- **Install:** `agentstack add skill-maxnorm-magento2-agent-skills-magento-model-developer`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [maxnorm](https://agentstack.voostack.com/s/maxnorm)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [maxnorm](https://github.com/maxnorm)
- **Source:** https://github.com/maxnorm/magento2-agent-skills/tree/main/skills/magento-model-developer

## Install

```sh
agentstack add skill-maxnorm-magento2-agent-skills-magento-model-developer
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Magento 2 Model Developer

Expert specialist in designing and implementing robust data layer architectures, creating efficient, scalable data models that serve as the foundation for enterprise e-commerce applications.

## When to Use

- Creating data models and entities
- Designing database schemas
- Implementing repository patterns
- Working with EAV or flat table structures
- Optimizing database queries
- Building data collections

## Data Architecture

- **Model Design**: Create efficient entity models following Magento patterns
- **EAV vs Flat Tables**: Choose optimal data storage strategies for different scenarios
- **Repository Pattern**: Implement clean data access layers and service contracts
- **Collection Optimization**: Build high-performance data collections and queries
- **Database Schema Design**: Design normalized, efficient database structures

## Model Development Process

### 1. Data Requirements Analysis
- **Business Requirements**: Understand entity relationships and business rules
- **Performance Requirements**: Plan for expected data volume and query patterns
- **Storage Strategy**: Choose between EAV and flat table storage approaches
- **Relationship Mapping**: Design entity relationships and dependencies
- **Scalability Planning**: Plan for future growth and data expansion

### 2. Database Schema Design
- **Table Structure**: Design efficient table structures and relationships
- **Data Types**: Choose appropriate data types for optimal storage and performance
- **Indexing Strategy**: Plan indexes for search, sorting, and filtering operations
- **Constraints**: Implement proper database constraints and validation
- **Migration Scripts**: Create database migration and upgrade scripts

### 3. Model Implementation
- **Entity Classes**: Implement model classes with proper validation and logic
- **Resource Models**: Create efficient database interaction layers
- **Collection Development**: Build optimized collection classes with filtering
- **Repository Implementation**: Create repository classes following service contracts
- **Factory Classes**: Implement proper object factories and builders

### 4. Integration & Testing
- **API Integration**: Integrate models with REST and GraphQL APIs
- **Cache Integration**: Implement proper caching strategies for model data
- **Performance Testing**: Validate model performance under expected load
- **Data Validation**: Test data integrity and validation rules
- **Migration Testing**: Test database migrations and data consistency

## Model Types

### Entity Model
```php
_init(ResourceModel::class);
    }
}
```

### Resource Model
```php
_init('vendor_module_entity', 'entity_id');
    }
}
```

### Collection
```php
_init(Entity::class, ResourceModel::class);
    }
}
```

### Repository Implementation
```php
resource->load($id);
        if (!$entity->getId()) {
            throw new NoSuchEntityException(__('Entity with id "%1" does not exist.', $id));
        }
        return $entity;
    }
}
```

## Database Schema (db_schema.xml)

```xml

    
        
        
        
        
            
        
        
            
        
    

```

## EAV vs Flat Tables

### EAV (Entity-Attribute-Value)
- Use for entities with many optional attributes
- Flexible attribute management
- Higher query complexity
- Use for products, customers, categories

### Flat Tables
- Use for entities with fixed attributes
- Better query performance
- Simpler data model
- Use for orders, quotes, simple entities

## Best Practices

### Performance
- **Query Optimization**: Optimize database queries and eliminate N+1 problems
- **Index Strategy**: Design efficient database indexing
- **Collection Optimization**: Use proper filters and pagination
- **Lazy Loading**: Implement lazy loading for expensive operations
- **Caching**: Cache frequently accessed data

### Data Integrity
- **Validation**: Implement comprehensive data validation
- **Constraints**: Use database constraints where appropriate
- **Transactions**: Use transactions for multi-step operations
- **Referential Integrity**: Maintain proper foreign key relationships
- **Data Consistency**: Ensure data consistency across operations

### Code Quality
- **Service Contracts**: Use interfaces for repositories
- **Type Hints**: Use proper type hints throughout
- **Error Handling**: Comprehensive error handling
- **Documentation**: Document data models and relationships
- **Testing**: Write tests for models and repositories

## References

- [Adobe Commerce Models](https://developer.adobe.com/commerce/php/development/components/model/)
- [Repository Pattern](https://developer.adobe.com/commerce/php/development/components/repository-pattern/)
- [Database Schema](https://developer.adobe.com/commerce/php/development/components/declarative-schema/)

Focus on creating efficient, scalable data models that serve as a solid foundation for enterprise applications.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [maxnorm](https://github.com/maxnorm)
- **Source:** [maxnorm/magento2-agent-skills](https://github.com/maxnorm/magento2-agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-maxnorm-magento2-agent-skills-magento-model-developer
- Seller: https://agentstack.voostack.com/s/maxnorm
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
