easygento / magento2-utils
带有一些工具的 Magento 2 模块,这些工具可以使开发工作和调试更加容易
0.2.3
2019-08-19 13:23 UTC
Requires
- php: ~7.0.0|~7.1.0|~7.2.0|~7.3.0
- magento/framework: 100.1.*|101.0.*|102.0.*
README
带有一些工具的 Magento 2 模块,这些工具可以使开发工作和调试更加容易
计划任务运行器
如何使用
bin/magento easygento:utils:cronrunner --cronClass="\My\CronClass\toRun"
自定义产品属性创建器
类 ProductUtils 对创建简单快速的自定义产品属性非常有用。在你的 InstallData/UpgradeData 中,调用 \Easygento\Utils\Model\ProductUtils 作为 DI,并使用其中的公共函数。要创建一个自定义产品属性,传递一个包含你的数据的数组作为参数:例如
$attributes = [
'another_custom_attribute' => [
'type' => 'varchar',
'label' => 'Another Custom Label',
'input' => 'text',
'source' => '',
'filterable' => false,
'visible_on_front' => true,
'used_in_product_listing' => false,
'attribute_group_name' => 'My Custom Attribute Group Name',
'backend' => ''
],
'another_custom_attribute_with_option' => [
'type' => 'int',
'label' => 'Type',
'input' => 'select',
'source' => '',
'filterable' => true,
'visible_on_front' => true,
'used_in_product_listing' => true,
'backend' => '',
'options' => [
'Option A',
'Option B',
'Option C',
'Option D',
'Option E',
'Option F'
]
],
'another_custom_attribute_boolean' =>[
'type' => 'int',
'label' => 'Shown In List',
'input' => 'select',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'filterable' => false,
'visible_on_front' => false,
'used_in_product_listing' => false,
'attribute_group_name' => 'Another Custom Attribute Group Name',
'attribute_set_name' => 'my custom Attribute Set Name',
'backend' => ''
],
'another_custom_attribute_multiselect' => [
'type' => 'varchar',
'label' => 'Collection',
'input' => 'multiselect',
'source' => '',
'filterable' => true,
'visible_on_front' => true,
'used_in_product_listing' => true,
'options' => [
'Collection A',
'Collection B',
'Collection C',
'Collection D',
],
'attribute_group_name' => 'Another Custom Attribute Group Name',
'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend'
],
];
自定义日志记录器
你所需要做的只是将类 \Easygento\Utils\Logger\Logger 注入到你的类中。然后你可以使用默认的方法,如 debug() , info() ...。日志将记录在默认路径 /var/log/easygento/debug.log。
你可以使用虚拟类型定义自己的日志路径。请参见 di.xml 文件中的示例。
如何安装此模块?
使用 composer
composer require easygento/magento2-utils:dev-master
不使用 composer
你可以下载最新版本并将其放入你的 app/code 文件夹
一旦模块安装完成,运行以下命令
bin/magento setup:upgrade
并
bin/magento setup:di:compile