designcoil/module-import-command 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

designcoil/module-import-command

Composer 安装命令:

composer require designcoil/module-import-command

包简介

CLI commands (product:import:validate, product:import:run) wrapping Magento's native ImportExport pipeline

README 文档

README

CLI commands that wrap Magento's native ImportExport pipeline - the exact same codepath used by Admin > System > Data Transfer > Import.

Useful for large catalog imports without Admin timeouts. Importing 10k–100k+ products through the Admin UI often results in PHP max execution time exceeded, browser session expiration, Cloudflare timeouts. Running imports via CLI avoids web server limits and is suitable for large catalogs and scheduled batch jobs.

Commands

Command Description
product:import:validate Validate a CSV import file and report errors
product:import:run Validate, import, and invalidate indexes

Requirements

  • Magento 2.4.x (Open Source or Commerce)
  • PHP 8.2, 8.3, or 8.4

Installation

Via Composer (recommended)

composer require designcoil/module-import-command
bin/magento module:enable DesignCoil_ImportCommand
bin/magento setup:upgrade
bin/magento setup:di:compile

Manual

Copy the module to app/code/DesignCoil/ImportCommand/, then:

bin/magento module:enable DesignCoil_ImportCommand
bin/magento setup:upgrade
bin/magento setup:di:compile

Usage

Validate a CSV file

bin/magento product:import:validate \
  --entity=catalog_product \
  --file=var/import/products.csv

Output on success:

Validation result: OK

Summary:
  Rows processed:       100
  Entities processed:   100
  Invalid rows:         0
  Total errors:         0
  Error limit exceeded: No

Output on failure:

Validation result: FAILED

Errors:
  Wrong URL/path used for attribute additional_images in row(s): 1, 2

Summary:
  Rows processed:       100
  Entities processed:   100
  Invalid rows:         2
  Total errors:         2
  Error limit exceeded: No

Run a full import

bin/magento product:import:run \
  --entity=catalog_product \
  --file=var/import/products.csv \
  --behavior=append \
  --images-file-dir=var/import/images

Output:

Validating import data...
Validation passed. Importing 100 row(s) in 1 batch(es)...
  1/1 batches [============================] 100%

Import completed successfully.

  Created: 80
  Updated: 20
  Deleted: 0

Summary:
  Rows processed:       100
  Entities processed:   100
  Invalid rows:         0
  Total errors:         0
  Error limit exceeded: No

CLI Options

All options are available on both commands.

Required

Option Description
--entity Entity type code: catalog_product, customer, customer_address, etc.
--file Path to CSV file. Absolute or relative to Magento root.

Import behavior

Option Default Description
--behavior append Import behavior: append, add_update, replace, delete

Validation

Option Default Description
--validation-strategy validation-stop-on-errors validation-stop-on-errors or validation-skip-errors
--allowed-error-count 10 Maximum number of errors before stopping

CSV format

Option Default Description
--field-separator , Column delimiter
--multiple-value-separator , Separator for multi-value fields
--enclosure " CSV field enclosure character
--fields-enclosure off Flag. Enables fields enclosed by double-quotes (matches Admin checkbox)

File & locale

Option Default Description
--images-file-dir (none) Images directory relative to Magento root (e.g. var/import/images)
--locale (none) Locale code for import (e.g. en_US)

How it works

  1. The CSV file is copied into var/importexport/ - the same temp location Magento's admin upload uses.
  2. A native Magento\ImportExport\Model\Import\Source\Csv adapter is created.
  3. Import::validateSource() validates the data and saves it to the database in batches.
  4. Import::importSource() reads those batches and performs the actual create/update/delete operations.
  5. Import::invalidateIndex() marks related indexers for reindex.

This is identical to clicking Check Data and then Import in the admin panel.

Examples

Product import with semicolon-delimited CSV:

bin/magento product:import:run \
  --entity=catalog_product \
  --file=/absolute/path/to/products.csv \
  --behavior=append \
  --field-separator=";" \
  --multiple-value-separator="|" \
  --images-file-dir=var/import/images \
  --fields-enclosure

Customer import, skip errors:

bin/magento product:import:run \
  --entity=customer \
  --file=var/import/customers.csv \
  --behavior=add_update \
  --validation-strategy=validation-skip-errors \
  --allowed-error-count=50

Validate only (dry run):

bin/magento product:import:validate \
  --entity=catalog_product \
  --file=var/import/products.csv \
  --validation-strategy=validation-skip-errors \
  --allowed-error-count=100 \
  --images-file-dir=var/import/images

License

MIT

designcoil/module-import-command 适用场景与选型建议

designcoil/module-import-command 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「csv」 「catalog」 「cli」 「import」 「magento2」 「product-import」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 designcoil/module-import-command 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 designcoil/module-import-command 我们能提供哪些服务?
定制开发 / 二次开发

基于 designcoil/module-import-command 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 36
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-12