0

I wish to change the default order of tabs in Product Information when adding a new product. I want to put the Categories tab beneath the General tab (or even above it) - like here:

tab order

I'm struggling to figure out how to do this, as the majority of guides deal with custom tabs and thus allow you to use the after tags in the layout.xml file. From what I have found, editing the Tabs.php (app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php) file is recommended by some - however; I tried to do this and it had no effect. Making the below code modification should have put the Catalog tab above the Inventory tab, but didn't:

$this->addTab('categories', array(
                'label'     => Mage::helper('catalog')->__('Categories'),
                'url'       => $this->getUrl('*/*/categories', array('_current' => true)),
                'class'     => 'ajax',
            ));

if (Mage::helper('core')->isModuleEnabled('Mage_CatalogInventory')) {
                $this->addTab('inventory', array(
                    'label'     => Mage::helper('catalog')->__('Inventory'),
                    'content'   => $this->_translateHtml($this->getLayout()
                        ->createBlock('adminhtml/catalog_product_edit_tab_inventory')->toHtml()),
                ));

(I know it's not ideal to edit core files, but I just wanted to test it.)

In any case, because I want the Categories tab beneath the General tab, I would need to edit this for loop which retrieves the user configurable tabs first no?

foreach ($groupCollection as $group) {
                $attributes = $product->getAttributes($group->getId(), true);
                // do not add groups without attributes

                foreach ($attributes as $key => $attribute) {
                    if( !$attribute->getIsVisible() ) {
                        unset($attributes[$key]);
                    }
                }

                if (count($attributes)==0) {
                    continue;
                }

                $this->addTab('group_'.$group->getId(), array(
                    'label'     => Mage::helper('catalog')->__($group->getAttributeGroupName()),
                    'content'   => $this->_translateHtml($this->getLayout()->createBlock($this->getAttributeTabBlock(),
                        'adminhtml.catalog.product.edit.tab.attributes')->setGroup($group)
                            ->setGroupAttributes($attributes)
                            ->toHtml()),
                ));
            }

Any suggestions? Thanks!

3 Answers 3

1

So it turns out that app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tabs.php is the correct file. I or someone else had copied it to the local directory so that copy was being used instead. Moving the categories tab above the inventory tab via manipulating their order in the code did work. I was also able to follow this guide:

http://www.netismine.com/magento/change-tab-order-in-product-admin

To hide my Additional Fields tab, then copy the code and reinclude the tab beneath the Categories tab, so that Categories appeared second. I also commented out the Up-sells etc tabs as I have no use of them.

If it helps, here is the code from the edits.php tab down to the Inventory tab:

protected function _prepareLayout()
{
    $product = $this->getProduct();

    if (!($setId = $product->getAttributeSetId())) {
        $setId = $this->getRequest()->getParam('set', null);
    }

    if ($setId) {
        $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
            ->setAttributeSetFilter($setId)
            ->setSortOrder()
           ->addFieldToFilter('attribute_group_id',array('nin'=>array('27'))) // using 'in' instead of 'nin' will only return these tabs
            ->load();

        foreach ($groupCollection as $group) {
            $attributes = $product->getAttributes($group->getId(), true);
            // do not add groups without attributes

            foreach ($attributes as $key => $attribute) {
                if( !$attribute->getIsVisible() ) {
                    unset($attributes[$key]);
                }
            }

            if (count($attributes)==0) {
                continue;
            }

            $this->addTab('group_'.$group->getId(), array(
                'label'     => Mage::helper('catalog')->__($group->getAttributeGroupName()),
                'content'   => $this->_translateHtml($this->getLayout()->createBlock($this->getAttributeTabBlock(),
                    'adminhtml.catalog.product.edit.tab.attributes')->setGroup($group)
                        ->setGroupAttributes($attributes)
                        ->toHtml()),
            ));
        }

        $this->addTab('categories', array(
            'label'     => Mage::helper('catalog')->__('Categories'),
            'url'       => $this->getUrl('*/*/categories', array('_current' => true)),
            'class'     => 'ajax',
        ));

        $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
            ->setAttributeSetFilter($setId)
            ->setSortOrder()
           ->addFieldToFilter('attribute_group_id',array('in'=>array('27'))) // using nin hides that tab id
            ->load();

        foreach ($groupCollection as $group) {
            $attributes = $product->getAttributes($group->getId(), true);
            // do not add groups without attributes

            foreach ($attributes as $key => $attribute) {
                if( !$attribute->getIsVisible() ) {
                    unset($attributes[$key]);
                }
            }

            if (count($attributes)==0) {
                continue;
            }

            $this->addTab('group_'.$group->getId(), array(
                'label'     => Mage::helper('catalog')->__($group->getAttributeGroupName()),
                'content'   => $this->_translateHtml($this->getLayout()->createBlock($this->getAttributeTabBlock(),
                    'adminhtml.catalog.product.edit.tab.attributes')->setGroup($group)
                        ->setGroupAttributes($attributes)
                        ->toHtml()),
            ));
        }

        $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
            ->setAttributeSetFilter($setId)
            ->setSortOrder()
           ->addFieldToFilter('attribute_group_id',array('in'=>array('27'))) // using 'in' only returns this tab ID
            ->load();

        if (Mage::helper('core')->isModuleEnabled('Mage_CatalogInventory')) {
            $this->addTab('inventory', array(
                'label'     => Mage::helper('catalog')->__('Inventory'),
                'content'   => $this->_translateHtml($this->getLayout()
                    ->createBlock('adminhtml/catalog_product_edit_tab_inventory')->toHtml()),
            ));
        }
0

You should be able to do this without PHP. When setting up the Categories tab you specific a sort order. General has a sort order of 10, so a 20 for "Categories" should work, for example, in the module's system.xml

<config>
    <sections>
        <company_categories module="company_categories">
            <tab>general</tab>
            <sort_order>20</sort_order>
        </company_categories>
    </sections>
</config>
1
  • Thanks for response. I'm struggling to find the correct xml file though - can you point me in the right direction? I didn't set up the Categories tab as it is a default. Cheers
    – Jingo
    Aug 6, 2015 at 10:48
0

There is an easy way of doing this, you can use addTabAfter($tabId, $tab, $afterTabId) function you can use it to place your tab anywhere in the list simply provide the tab id of that tab. Tab id get the name of the tab and as you want to move category tab under general then you can provide $afterTabId='group_7';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.