17 class NewCategory extends \Magento\Backend\Block\Widget\Form\Generic
46 $this->_categoryFactory = $categoryFactory;
48 $this->setUseContainer(
true);
59 $form = $this->_formFactory->create([
'data' => [
'id' =>
'new_category_form',
'class' =>
'admin__scope-old']]);
60 $form->setUseContainer($this->getUseContainer());
62 $form->addField(
'new_category_messages',
'note', []);
64 $fieldset = $form->addFieldset(
'new_category_form_fieldset', []);
70 'label' =>
__(
'Category Name'),
71 'title' =>
__(
'Category Name'),
73 'name' =>
'new_category_name' 78 'new_category_parent',
81 'label' =>
__(
'Parent Category'),
82 'title' =>
__(
'Parent Category'),
85 'class' =>
'validate-parent-category',
86 'name' =>
'new_category_parent',
89 'If there are no custom parent categories, please use the default parent category. ' .
90 'You can reassign the category at any time in ' .
91 '<a href="%1" target="_blank">Products > Categories</a>.',
92 $this->
getUrl(
'catalog/category')
108 $items = $this->_categoryFactory->create()->getCollection()->addAttributeToSelect(
110 )->addAttributeToSort(
115 )->load()->getItems();
118 if (count(
$items) === 2) {
133 return $this->
getUrl(
'catalog/category/save');
143 $widgetOptions = $this->_jsonEncoder->encode(
145 'suggestOptions' => [
146 'source' => $this->
getUrl(
'catalog/category/suggestCategories'),
147 'valueField' =>
'#new_category_parent',
148 'className' =>
'category-select',
149 'multiselect' =>
true,
152 'saveCategoryUrl' => $this->
getUrl(
'catalog/category/save'),
158 require([
"jquery",
"mage/mage"],
function($) {
160 $(
'#new-category').
mage(
'newCategoryDialog', $widgetOptions);
_getParentCategoryOptions()
if( $form)() ?>< script > require(['jquery' mage mage
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Catalog\Model\CategoryFactory $categoryFactory, array $data=[])
getUrl($route='', $params=[])