Commit c11e36a2 by halweg

feat: custom menu group

parent f67f2b9f
......@@ -21,6 +21,12 @@ class InstallData implements InstallDataInterface
)
{
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttributeGroup(
\Magento\Catalog\Model\Category::ENTITY,
$eavSetup->getDefaultAttributeSetId(\Magento\Catalog\Model\Category::ENTITY),
'Custom Menu',
99
);
$eavSetup->addAttribute(
\Magento\Catalog\Model\Category::ENTITY,
'badge',
......@@ -35,7 +41,7 @@ class InstallData implements InstallDataInterface
'required' => false,
'user_defined' => false,
'default' => null,
'group' => '',
'group' => 'Custom Menu',
'backend' => ''
]
);
......
<?php
namespace Joshine\Category\Setup;
use Magento\Framework\Module\Setup\Migration;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Catalog\Setup\CategorySetupFactory;
/**
* Data migration:
* - Config Migration from version 2.0.1 JSON file store to 2.0.2+ Magento config way
*
*/
class UpgradeData implements UpgradeDataInterface
{
private $categorySetupFactory;
public function __construct(CategorySetupFactory $categorySetupFactory)
{
$this->categorySetupFactory = $categorySetupFactory;
}
/**
* Run data upgrade.
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '1.0.1') < 0) {
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Category::ENTITY);
$attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
$idg = $categorySetup->getAttributeGroupId($entityTypeId, $attributeSetId, 'Custom Menu');
$categorySetup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
$idg,
'badge',
1
);
}
$setup->endSetup();
}
}
<?xml version="1.0" ?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="display_settings">
<fieldset name="custom_menu">
<settings>
<collapsible>true</collapsible>
<label translate="false">Custom Menu</label>
</settings>
<field name="badge" sortOrder="300">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Joshine\Category\Model\Category\Attribute\Source\Badge</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment