magently/module-content-setup
Composer 安装命令:
composer require magently/module-content-setup
包简介
Magently Content Setup module for Magento 2.
README 文档
README
Installation
To install the module, run the following commands:
composer require magently/module-content-setup
php bin/magento setup:upgrade
Usage
Now you can use the module in your code.
Inject Magently\ContentSetup\Model\ContentSetupFactory in your UpgradeData / PatchData class - a Factory is used here so that you can use this module in different modules in the project, for example:
public function __construct(\Magently\ContentSetup\Model\ContentSetupFactory $contentSetupFactory)
{
$this->contentSetupFactory = $contentSetupFactory;
}
Then create an object from a Factory passing the name of your module, for example:
/** @var \Magently\ContentSetup\Model\ContentSetup $setup */
$setup = $this->contentSetupFactory->create(['moduleName' => 'Magently_TestModule']);
From now on, you can use the module to upload your content:
$setup->setupPage('test_page');
$setup->setupBlock('test_block');
$setup->setupEmailTemplate('test_email');
$setup->setupVariable('test_variable', 'TEST VARIABLE');
Cms Pages, Cms Blocks and Email Templates must be placed in the structure of your module:
app/code/VendorName/ModuleName/Setup/Content/{COMPONENT_NAME}, e.g.
app/code/Magently/TestModule/Setup/Content/Block/test_block.html and app/code/Magently/TestModule/Setup/Content/Block/test_block.php
files will be used to create / update a block with a test_block identifier. Put the content of the block in the .html file. In the .php file, put the data as an array with keys such as name or is_active:
// file: app/code/Magently/TestModule/Setup/Content/Block/test_block.php
<?php
return [
'title' => 'Magently Test Block',
'identifier' => 'test_block',
'is_active' => 1
];
Declare Magento Variables as below, without any files:
public function setupVariable(
string $code,
string $name = null,
string $plainValue = null,
string $htmlValue = null
)
More information
You can find more about how the module works on our Magently blog: https://magently.com/blog/add-magento-cms-blocks-programmatically
In case of problems or ideas on how to improve the module, don't hestiate to open a pull request.
magently/module-content-setup 适用场景与选型建议
magently/module-content-setup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.67k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 magently/module-content-setup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 magently/module-content-setup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.67k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: OSL-3.0
- 更新时间: 2022-08-26