supravatm/magento2-module-fake-data-api
Composer 安装命令:
composer require --dev supravatm/magento2-module-fake-data-api
包简介
A lightweight and non-intrusive(no DB bloat unless you extend it to save) Magento 2 module to generate fake customers, products, and orders via GraphQL & REST APIs.
关键字:
README 文档
README
A lightweight and non-intrusive(no DB bloat unless you extend it to save) developer-friendly Magento 2 module to generate fake customers, products, and orders via GraphQL & REST APIs. Powered by FakerPHP.
Useful when:
✅ You need quick test data for local/staging development
✅ Testing GraphQL storefronts (Vue, React, PWA Studio, etc.)
✅ Avoiding manual CSV uploads or repetitive admin work
🚀 Features
- Generate Customers, Products, and Orders with one API call
- Supports REST (
/V1/mockdata/generate) and GraphQL - Customizable
entityandnumberOfItemsparameters - Lightweight and non-intrusive (no DB bloat unless you extend it to save)
📦 Installation
Install via Composer (recommended)
If your module is published on Packagist, you can install it directly:
composer require --dev supravatm/magento2-module-fake-data-api bin/magento module:enable SMG_MockDataGenerator bin/magento setup:upgrade
Preferred way : easier upgrades, dependency management, Packagist support.
Manual Installation (alternative)
Download the module .zip or clone the repo. Extract it into Magento’s app/code directory:
mkdir -p app/code/SMG
cd app/code/SMG
git clone git@github.com:supravatm/magento2-fake-data-api.git MockDataGenerator
bin/magento module:enable SMG_MockDataGenerator
bin/magento setup:upgrade
bin/magento cache:flush
🔧 Usage
✅ REST API
Endpoint:
POST /rest/V1/mockdata/generate
Body Example:
{
"entity": "product",
"numberOfItems": 1,
"searchCriteria": {
"pageSize": 10,
"currentPage": 1
}
}
Response:
{
"items": [
{
"entity_id": 1,
"sku": "FAKE-8051WX",
"name": "Portable Smartphone",
"attribute_set_id": 4,
"price": 893.19,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2025-03-02 06:40:17",
"updated_at": "2025-09-14 22:45:57",
"weight": 1.92,
"extension_attributes": {
"website_ids": [
1
],
"category_links": [
{
"position": 0,
"category_id": "3",
"extension_attributes": {}
}
],
"stock_item": {
"item_id": 0,
"product_id": 0,
"stock_id": 1,
"qty": 32,
"is_in_stock": false,
"use_config_manage_stock": true,
"manage_stock": true,
"extension_attributes": {}
}
},
"product_links": [],
"options": [],
"media_gallery_entries": [],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "description",
"value": "High-quality Portable Smartphone with long battery life."
},
{
"attribute_code": "short_description",
"value": "Stylish portable smartphone available in navy."
},
{
"attribute_code": "color",
"value": "navy"
}
]
}
],
"search_criteria": {
"filter_groups": [],
"page_size": 1,
"current_page": 1
},
"total_count": 1
}
✅ GraphQL
Query:
{
MockDataProduct(numberOfItems: 1) {
items {
entity_id
name
price
sku
status
type_id
visibility
weight
}
total_count
}
}
Response:
{
"data": {
"MockDataProduct": {
"items": [
{
"entity_id": 1,
"name": "Smart Backpack",
"price": 531.97,
"sku": "FAKE-0348VS",
"status": 1,
"type_id": "simple",
"visibility": 4,
"weight": 4.41
}
],
"total_count": 1
}
}
}
{
MockDataCustomer(numberOfItems: 1) {
items {
addresses
{
street
country_id
}
id
email
}
total_count
}
}
Response:
{
"data": {
"MockDataCustomer": {
"items": [
{
"addresses": [
{
"street": [
"23973 Maxime Grove"
],
"country_id": "US"
},
{
"street": [
"9718 Jonathan Rapid Apt. 836"
],
"country_id": "US"
}
],
"id": 540,
"email": "hartmann.dexter@example.net"
}
],
"total_count": 1
}
}
}
{
MockDataOrder(numberOfItems: 1) {
items {
billing_address {
street
city
country_id
}
customer_email
increment_id
grand_total
items {
sku
name
qty_ordered
}
payment {
method
amount_paid
}
shipping_amount
state
status
status_histories {
comment
status
}
}
total_count
}
}
Response:
{
"data": {
"MockDataOrder": {
"items": [
{
"billing_address": {
"street": [
"4994 Jakubowski Bypass"
],
"city": "Port Keatonville",
"country_id": "SA"
},
"customer_email": "queen.osinski@example.net",
"increment_id": "427471870",
"grand_total": 1533.49,
"items": [
{
"sku": "SKU-668UB",
"name": "Ergonomic Laptop",
"qty_ordered": 3
}
],
"payment": {
"method": "paypal",
"amount_paid": 1533.49
},
"shipping_amount": 13.93,
"state": "closed",
"status": "pending",
"status_histories": [
{
"comment": "Package delayed due to carrier issues. Informed customer.",
"status": "complete"
}
]
}
],
"total_count": 1
}
}
}
⚙️ Supported Entities
customerproductorder
(You can extend this to support categories, reviews, invoices, etc.)
🧑💻 Development Notes
- Uses FakerPHP for data generation
- Data is returned via API response only (does not save to DB by default)
- You can extend
MockDataRepository.phpto insert generated entities into Magento DB
📝 License
This repository is licensed under the MIT License. Feel free to fork, modify, and share.
© 2025 Supravat Mondal. All rights reserved.
supravatm/magento2-module-fake-data-api 适用场景与选型建议
supravatm/magento2-module-fake-data-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 09 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「products」 「orders」 「testing」 「fake-data」 「customers」 「dev-tools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 supravatm/magento2-module-fake-data-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 supravatm/magento2-module-fake-data-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 supravatm/magento2-module-fake-data-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
Add Shopify like fulfillments to your Craft Commerce orders.
Submodule for SilverShop which allows you to compare products in a table.
The PHP SDK for Checkmango
Product catalog for your Symfony2 applications.
Auto generate related products for Magento 2
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-17