Ejemplo n.º 1
0
 /**
  * Prepare Layout Content
  *
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _prepareLayout()
 {
     $this->addTab('category', ['label' => __('Category information'), 'content' => $this->getLayout()->createBlock('Mageplaza\\Blog\\Block\\Adminhtml\\Category\\Edit\\Tab\\Category', 'mageplaza_blog_category_edit_tab_category')->toHtml()]);
     $this->addTab('post', ['label' => __('Posts'), 'content' => $this->getLayout()->createBlock('Mageplaza\\Blog\\Block\\Adminhtml\\Category\\Edit\\Tab\\Post', 'mageplaza_blog_category_edit_tab_post')->toHtml()]);
     // dispatch event add custom tabs
     $this->_eventManager->dispatch('adminhtml_mageplaza_blog_category_tabs', ['tabs' => $this]);
     return parent::_prepareLayout();
 }
Ejemplo n.º 2
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     $role = $this->_coreRegistry->registry('current_role');
     $this->addTab('info', $this->getLayout()->createBlock('Magento\\User\\Block\\Role\\Tab\\Info')->setRole($role)->setActive(true));
     if ($role->getId()) {
         $this->addTab('roles', array('label' => __('Role Users'), 'title' => __('Role Users'), 'content' => $this->getLayout()->createBlock('Magento\\User\\Block\\Role\\Tab\\Users', 'role.users.grid')->toHtml()));
     }
     return parent::_prepareLayout();
 }
Ejemplo n.º 3
0
 /**
  * Prepare layout for dashboard bottom tabs
  *
  * To load block statically:
  *     1) content must be generated
  *     2) url should not be specified
  *     3) class should not be 'ajax'
  * To load with ajax:
  *     1) do not load content
  *     2) specify url (BE CAREFUL)
  *     3) specify class 'ajax'
  *
  * @return $this
  */
 protected function _prepareLayout()
 {
     // load this active tab statically
     $this->addTab('ordered_products', array('label' => __('Bestsellers'), 'content' => $this->getLayout()->createBlock('Magento\\Backend\\Block\\Dashboard\\Tab\\Products\\Ordered')->toHtml(), 'active' => true));
     // load other tabs with ajax
     $this->addTab('reviewed_products', array('label' => __('Most Viewed Products'), 'url' => $this->getUrl('adminhtml/*/productsViewed', array('_current' => true)), 'class' => 'ajax'));
     $this->addTab('new_customers', array('label' => __('New Customers'), 'url' => $this->getUrl('adminhtml/*/customersNewest', array('_current' => true)), 'class' => 'ajax'));
     $this->addTab('customers', array('label' => __('Customers'), 'url' => $this->getUrl('adminhtml/*/customersMost', array('_current' => true)), 'class' => 'ajax'));
     return parent::_prepareLayout();
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareLayout()
 {
     $this->addTab('general', ['label' => __('General'), 'content' => $this->getLayout()->createBlock('Magento\\Backend\\Block\\System\\Design\\Edit\\Tab\\General')->toHtml()]);
     return parent::_prepareLayout();
 }
Ejemplo n.º 5
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     $this->addTab('orders', ['label' => __('Orders'), 'content' => $this->getLayout()->createBlock('Magento\\Backend\\Block\\Dashboard\\Tab\\Orders')->toHtml(), 'active' => true]);
     $this->addTab('amounts', ['label' => __('Amounts'), 'content' => $this->getLayout()->createBlock('Magento\\Backend\\Block\\Dashboard\\Tab\\Amounts')->toHtml()]);
     return parent::_prepareLayout();
 }
Ejemplo n.º 6
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     $this->setChild('userGrid', $this->getLayout()->createBlock('Magento\\User\\Block\\Role\\Grid\\User', 'roleUsersGrid'));
     return parent::_prepareLayout();
 }
Ejemplo n.º 7
0
 /**
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareLayout()
 {
     $product = $this->getProduct();
     if (!($setId = $product->getAttributeSetId())) {
         $setId = $this->getRequest()->getParam('set', null);
     }
     if ($setId) {
         $tabAttributesBlock = $this->getLayout()->createBlock($this->getAttributeTabBlock(), $this->getNameInLayout() . '_attributes_tab');
         $advancedGroups = [];
         foreach ($this->getGroupCollection($setId) as $group) {
             /** @var $group \Magento\Eav\Model\Entity\Attribute\Group*/
             $attributes = $product->getAttributes($group->getId(), true);
             foreach ($attributes as $key => $attribute) {
                 $applyTo = $attribute->getApplyTo();
                 if (!$attribute->getIsVisible() || !empty($applyTo) && !in_array($product->getTypeId(), $applyTo)) {
                     unset($attributes[$key]);
                 }
             }
             if ($attributes) {
                 $tabData = ['label' => __($group->getAttributeGroupName()), 'content' => $this->_translateHtml($tabAttributesBlock->setGroup($group)->setGroupAttributes($attributes)->toHtml()), 'class' => 'user-defined', 'group_code' => $group->getTabGroupCode() ?: self::BASIC_TAB_GROUP_CODE];
                 if ($tabData['group_code'] === self::BASIC_TAB_GROUP_CODE) {
                     $this->addTab($group->getAttributeGroupCode(), $tabData);
                 } else {
                     $advancedGroups[$group->getAttributeGroupCode()] = $tabData;
                 }
             }
         }
         /* Don't display website tab for single mode */
         if (!$this->_storeManager->isSingleStoreMode()) {
             $this->addTab('websites', ['label' => __('Websites'), 'content' => $this->_translateHtml($this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\Websites')->toHtml()), 'group_code' => self::BASIC_TAB_GROUP_CODE]);
         }
         if (isset($advancedGroups['advanced-pricing'])) {
             $this->addTab('advanced-pricing', $advancedGroups['advanced-pricing']);
             unset($advancedGroups['advanced-pricing']);
         }
         if ($this->_moduleManager->isEnabled('Magento_CatalogInventory')) {
             $this->addTab('advanced-inventory', ['label' => __('Advanced Inventory'), 'content' => $this->_translateHtml($this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Product\\Edit\\Tab\\Inventory')->toHtml()), 'group_code' => self::ADVANCED_TAB_GROUP_CODE]);
         }
         /**
          * Do not change this tab id
          */
         if ($this->getChildBlock('customer_options')) {
             $this->addTab('customer_options', 'customer_options');
             $this->getChildBlock('customer_options')->setGroupCode(self::ADVANCED_TAB_GROUP_CODE);
         }
         $this->addTab('related', ['label' => __('Related Products'), 'url' => $this->getUrl('catalog/*/related', ['_current' => true]), 'class' => 'ajax', 'group_code' => self::ADVANCED_TAB_GROUP_CODE]);
         $this->addTab('upsell', ['label' => __('Up-sells'), 'url' => $this->getUrl('catalog/*/upsell', ['_current' => true]), 'class' => 'ajax', 'group_code' => self::ADVANCED_TAB_GROUP_CODE]);
         $this->addTab('crosssell', ['label' => __('Cross-sells'), 'url' => $this->getUrl('catalog/*/crosssell', ['_current' => true]), 'class' => 'ajax', 'group_code' => self::ADVANCED_TAB_GROUP_CODE]);
         if (isset($advancedGroups['design'])) {
             $this->addTab('design', $advancedGroups['design']);
             unset($advancedGroups['design']);
         }
         if ($this->getChildBlock('product-alerts')) {
             $this->addTab('product-alerts', 'product-alerts');
             $this->getChildBlock('product-alerts')->setGroupCode(self::ADVANCED_TAB_GROUP_CODE);
         }
         if (isset($advancedGroups['autosettings'])) {
             $this->addTab('autosettings', $advancedGroups['autosettings']);
             unset($advancedGroups['autosettings']);
         }
         foreach ($advancedGroups as $groupCode => $group) {
             $this->addTab($groupCode, $group);
         }
     }
     return parent::_prepareLayout();
 }
Ejemplo n.º 8
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     $this->setChild('listsGrid', $this->getLayout()->createBlock('Sugarcode\\Test\\Block\\Adminhtml\\Lists\\Edit\\Tab\\Gridtabs', 'listsTabsGrid'));
     return parent::_prepareLayout();
 }
Ejemplo n.º 9
0
 /**
  * Prepare Layout Content
  *
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _prepareLayout()
 {
     $categoryAttributes = $this->getCategory()->getAttributes();
     if (!$this->getCategory()->getId()) {
         foreach ($categoryAttributes as $attribute) {
             $default = $attribute->getDefaultValue();
             if ($default != '') {
                 $this->getCategory()->setData($attribute->getAttributeCode(), $default);
             }
         }
     }
     $attributeSetId = $this->getCategory()->getDefaultAttributeSetId();
     /** @var $groupCollection \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection */
     $groupCollection = $this->_collectionFactory->create()->setAttributeSetFilter($attributeSetId)->setSortOrder()->load();
     $defaultGroupId = 0;
     foreach ($groupCollection as $group) {
         /* @var $group \Magento\Eav\Model\Entity\Attribute\Group */
         if ($defaultGroupId == 0 or $group->getIsDefault()) {
             $defaultGroupId = $group->getId();
         }
     }
     foreach ($groupCollection as $group) {
         /* @var $group \Magento\Eav\Model\Entity\Attribute\Group */
         $attributes = [];
         foreach ($categoryAttributes as $attribute) {
             /* @var $attribute \Magento\Eav\Model\Entity\Attribute */
             if ($attribute->isInGroup($attributeSetId, $group->getId())) {
                 $attributes[] = $attribute;
             }
         }
         // do not add grops without attributes
         if (!$attributes) {
             continue;
         }
         $active = $defaultGroupId == $group->getId();
         $block = $this->getLayout()->createBlock($this->getAttributeTabBlock(), $this->getNameInLayout() . '_tab_' . $group->getAttributeGroupName())->setGroup($group)->setAttributes($attributes)->setAddHiddenFields($active)->toHtml();
         $this->addTab('group_' . $group->getId(), ['label' => __($group->getAttributeGroupName()), 'content' => $block, 'active' => $active]);
     }
     $this->addTab('products', ['label' => __('Category Products'), 'content' => $this->getLayout()->createBlock('Magento\\Catalog\\Block\\Adminhtml\\Category\\Tab\\Product', 'category.product.grid')->toHtml()]);
     // dispatch event add custom tabs
     $this->_eventManager->dispatch('adminhtml_catalog_category_tabs', ['tabs' => $this]);
     /*$this->addTab('features', array(
       'label'     => __('Feature Products'),
       'content'   => 'Feature Products'
       ));        */
     return parent::_prepareLayout();
 }
Ejemplo n.º 10
0
 protected function _prepareLayout()
 {
     //  $lists = $this->_coreRegistry->registry('lists');
     $this->addTabAfter('gridtabs', ['label' => __('Grid Tabs'), 'title' => __('Grid Tabs'), 'content' => $this->getLayout()->createBlock('Sugarcode\\Test\\Block\\Adminhtml\\Lists\\Edit\\Tab\\Gridtabs', 'test.lists.grid.tabs')->setActive(true)->toHtml()], 'main_section');
     return parent::_prepareLayout();
 }