定制 team23/module-setupmodule 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

team23/module-setupmodule

Composer 安装命令:

composer require team23/module-setupmodule

包简介

Setup Module for Magento 2 by TEAM23

README 文档

README

The SetupModule makes it easy to install new persistent data for your current Magento 2 project.

It allows adding of the following Magento 2 data:

  • EAV attribute groups
  • EAV attributes
  • content pages
  • content blocks
  • customer groups (TBD / WIP!)
  • menus (TBD / WIP!)

How to

If you want to setup data, just add the resource folders as described in the following sections in your themes Team23_SetupModule module override and run bin/magento setup:upgrade. All resources with a version >= the setup version stored in core_config_data's path team23/setup_module/version will become installed.

In rare cases when you want to repeat the installation process, just change the config with path team23/setup_module/version stored in core_config_data in the database.

Example directory structure

In app/design/frontend/VENDOR/THEME/Team23_SetupModule/

app
|-- ...
`-- design
    |-- ...
    `-- frontend
        |-- ...
        `-- VENDOR
            `-- THEME
                |-- ... 
                `-- Team23_SetupModule
                    `-- resources
                        |-- attribute
                        |-- attribute_group
                        |-- block
                        |-- customer_group      # (TBD / WIP!)
                        |-- menu                # (TBD / WIP!)
                        `-- page

How it works internally

Whenever bin/magento setup:upgrade will be run the extension will

  • look in its data resource folders for defined and valid xml files (i.e. filename_1.0.0.xml)
  • extract the files version number of the files & compare it with the current setup version in the database (in core_config_data: team23/setup_module/version)
  • run creation for all resources with a higher version than the setup version stored in the database (initially 0.0.0)
  • increase the setup version in the database to the highest version of all resources

Installation via Composer

  • Add satis.team23.de composer repository in your composer.json
composer config repositories.team23 composer https://satis.team23.de/
  • Require team23/module-setupmodule
composer require team23/module-setupmodule ^dev-master

Resources

General File naming:

Resource files will be read from resources/{TYPE}/.
To add a new resource file add a XML file with the of your choice. The file MUST end on (_) followed by a php compatible version number >= 1.0.0 and the file extension .xml e.g. new-attribute_1.0.0.xml.

The xml tags contents refer to the resources creation parameters, that Magento 2 uses in its functions. Therefore they MUST follow Magentos internal requirements (i.e. attribute codes must be written in snake_case).

Attribute resources

Attribute files will be read from resources/attribute.

Mandatory tags

  • xml - the surrounding root tag
  • code - the attribute code

Optional tags

The following optional attributes are currently supported. For more information check the Product EAV Attribute Options Reference

  • input
  • label
  • type
  • source
  • visible - defaults to 0
  • required - defaults to 0
  • user_defined - defaults to 0
  • default
  • searchable - defaults to 0
  • filterable - defaults to 0
  • comparable - defaults to 0
  • visible_on_front - defaults to 0
  • is_used_in_grid - defaults to 0
  • is_filterable_in_grid - defaults to 0
  • used_in_product_listing - defaults to 0
  • backend

IMPORTANT NOTE
When using source or backend tags, make sure the provided class is defined, otherwise that will lead to errors once
stored in the database. That's why SetupModule will throw an Exception if the class is not already defined.

Example

<xml>
    <code>my_custom_code</code>
    <input>text</input>
    <label>My label text</label>
    <visible>1</visible>
    <required>0</required>
    <user_defined>1</user_defined>
    <searchable>0</searchable>
    <filterable>0</filterable>
    <comparable>0</comparable>
    <visible_on_front>1</visible_on_front>
    <is_used_in_grid>0</is_used_in_grid>
    <used_in_product_listing>1</used_in_product_listing>
    <group>My example group</group>
</xml>

Attribute Group resources

Attribute Group files will be read from resources/attribute_group.

Mandatory tags

  • xml - the surrounding root tag
  • name - the groups name

Optional tags

  • sort_order

Example

<xml>
    <name>Demo Group</name>
    <sort_order>1</sort_order>
</xml>

Block resources

Block files will be read from resources/block.

Mandatory tags

  • xml - the surrounding root tag
  • identifier - the blocks unique identifier (must be snake_case)
  • title - the blocks title

Optional tags

  • content - defaults to ''; Feel free to use CDATA for unescaped html
  • store_id - defaults to 0
  • is_active - defaults to 0

Example

<xml>
    <identifier>block_mydemo</identifier>
    <title>My demo block</title>
    <content><![CDATA[<h2>My demo title in HTML</h2>
<p>Foo bar baz!</p>]]></content>
    <store_id>0</store_id>
    <is_active>1</is_active>
</xml>

Page resources

Page files will be read from resources/page.

Mandatory tags

  • xml - the surrounding root tag
  • identifier - the pages unique identifier (must be snake_case)
  • title - the pages title

Optional tags

  • content_heading
  • content - defaults to ''; Feel free to use CDATA for unescaped html
  • store_id - defaults to 0
  • is_active - defaults to 0
  • page_layout - defaults to 1column

Example

<xml>
    <identifier>no-route</identifier>
    <title>404 - My custom 404 override</title>
    <content_heading>404 - This is my overrides content heading</content_heading>
    <content>
        <![CDATA[
    <div class="error-section">
        <p>Im sorry...</p>
        <div class="error-row">
            <a href="/">Back to home</a>
        </div>
    </div>
    ]]>
    </content>
    <store_id>0</store_id>
    <is_active>1</is_active>
    <page_layout>1column</page_layout>
</xml>

team23/module-setupmodule 适用场景与选型建议

team23/module-setupmodule 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2024-06-13