Exemplo n.º 1
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     $addUrl = $this->getUrl("*/*/add", ['_current' => true, 'id' => null, '_query' => false]);
     $this->addChild('add_sub_button', 'Magento\\Backend\\Block\\Widget\\Button', ['label' => __('Add Subcategory'), 'onclick' => "addNew('" . $addUrl . "', false)", 'class' => 'add', 'id' => 'add_subcategory_button', 'style' => $this->canAddSubCategory() ? '' : 'display: none;']);
     if ($this->canAddRootCategory()) {
         $this->addChild('add_root_button', 'Magento\\Backend\\Block\\Widget\\Button', ['label' => __('Add Root Category'), 'onclick' => "addNew('" . $addUrl . "', true)", 'class' => 'add', 'id' => 'add_root_category_button']);
     }
     return parent::_prepareLayout();
 }
Exemplo n.º 2
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     $category = $this->getCategory();
     $categoryId = (int) $category->getId();
     // 0 when we create category, otherwise some value for editing category
     $this->setChild('tabs', $this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Category\\Tabs', 'tabs'));
     // Save button
     if (!$category->isReadonly() && $this->hasStoreRootCategory()) {
         $this->addButton('save', ['id' => 'save', 'label' => __('Save Category'), 'class' => 'save primary save-category', 'data_attribute' => ['mage-init' => ['Magento_Catalog/catalog/category/edit' => ['url' => $this->getSaveUrl(), 'ajax' => true]]]]);
     }
     // Delete button
     if ($categoryId && !in_array($categoryId, $this->getRootIds()) && $category->isDeleteable()) {
         $this->addButton('delete', ['id' => 'delete', 'label' => __('Delete Category'), 'onclick' => "categoryDelete('" . $this->getDeleteUrl() . "')", 'class' => 'delete']);
     }
     // Reset button
     if (!$category->isReadonly() && $this->hasStoreRootCategory()) {
         $resetPath = $categoryId ? 'catalog/*/edit' : 'catalog/*/add';
         $this->addButton('reset', ['id' => 'reset', 'label' => __('Reset'), 'onclick' => "categoryReset('" . $this->getUrl($resetPath, $this->getDefaultUrlParams()) . "',true)", 'class' => 'reset']);
     }
     return parent::_prepareLayout();
 }
Exemplo n.º 3
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     if ($head = $this->getLayout()->getBlock('head')) {
         $head->addChild('magento-adminhtml-catalog-category-edit-js', 'Magento\\Theme\\Block\\Html\\Head\\Script', array('file' => 'Magento_Catalog::catalog/category/edit.js'));
     }
     $category = $this->getCategory();
     $categoryId = (int) $category->getId();
     // 0 when we create category, otherwise some value for editing category
     $this->setChild('tabs', $this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Category\\Tabs', 'tabs'));
     // Save button
     if (!$category->isReadonly() && $this->hasStoreRootCategory()) {
         $this->addButton('save', array('id' => 'save', 'label' => __('Save Category'), 'onclick' => "categorySubmit('" . $this->getSaveUrl() . "', true)", 'class' => 'save primary save-category'));
     }
     // Delete button
     if ($categoryId && !in_array($categoryId, $this->getRootIds()) && $category->isDeleteable()) {
         $this->addButton('delete', array('id' => 'delete', 'label' => __('Delete Category'), 'onclick' => "categoryDelete('" . $this->getUrl('catalog/*/delete', array('_current' => true)) . "', true, {$categoryId})", 'class' => 'delete'));
     }
     // Reset button
     if (!$category->isReadonly() && $this->hasStoreRootCategory()) {
         $resetPath = $categoryId ? 'catalog/*/edit' : 'catalog/*/add';
         $this->addButton('reset', array('id' => 'reset', 'label' => __('Reset'), 'onclick' => "categoryReset('" . $this->getUrl($resetPath, array('_current' => true)) . "',true)", 'class' => 'reset'));
     }
     return parent::_prepareLayout();
 }