catgento / magento-2-category-importer
为 Magento 2 的分类导入器
1.0.7
2020-04-05 05:11 UTC
Requires
- php: ~7.1.3||~7.2.0||~7.3.0
- magento/framework: >=100.0.0
- magento/module-backend: >=100.0.0
- magento/module-cron: >=100.0.0
This package is auto-updated.
Last update: 2024-09-05 12:08:49 UTC
README
这是一个 Magento 模块,它向 bin/magento shell 添加了一个新命令,用于从 CSV 文件导入分类。
它已被从 https://github.com/macopedia/CategoryImporter 复制,但我已删除了新分类属性创建(这对于创建该模块的开发者来说是特定的)。
我还包括了一个自定义的 Magento 1 导出 shell 脚本 (https://gist.github.com/paugnu/2c680ea9f452a5b671e8d3c0f35ca34f),这样您就可以从您的 Magento 1 安装中生成 CSV 文件。
安装
Composer
composer require catgento/magento-2-category-importer
ZIP 文件
下载模块并将其解压到 app/code/Catgento/CategoryImporter 文件夹下。
如何使用它
创建包含分类信息的 CSV 文件
必填列
id
name
parent_id
is_active
is_anchor
include_in_menu
custom_use_parent_settings
description
可选列
meta_title
meta_keywords
meta_description
url_key
url_path
您还可以添加自定义列,并在调用脚本时指定它们。
用于导出分类的 Magento 1 shell 脚本
将此 gist 中的 shell 脚本 https://gist.github.com/catgento/2c680ea9f452a5b671e8d3c0f35ca34f (exportCategoriesCsv.php) 复制到您的 Magento 1 安装的 shell/ 文件夹中。您只需要在该文件夹内执行它,并将输出放在 CSV 文件中,如下所示
php exportCategoriesCsv.php > categories_m1.csv
注意
- 此脚本将引号 " 替换为 '«' 和 '»'。有更好的方法,但我更喜欢这样做以避免转义问题。
在 Magento 2 中导入 CSV 文件
如 Macomedia 模块中所述,您可以通过以下方式使用此模块:
bin/magento import:categories [--path|-p <path to file in Magento dir>] [--additional|-a <additional attributes separated by comma>]
bin/magento import:categories -p var/import/categories-example.csv
bin/magento import:categories -p var/import/categories-example.csv -a my_custom_attribute1,my_custom_attribute2,my_custom_attribute3