Month: February 2010

Magento – undefined index in “toolbar.phtml” – after changing default sort by

Recently I added a new product-attribute and it was set to be the default sortby attribute. To my surprise, I used to get an undefined index on some categories.
I failed to get a clear solution in any of the article from Magentocommerce site. On further investigation I realised that just setting the default sort by option will not be sufficient.
It is also necessary to check if you have selected this new attribute in the list of “Available Product Listing Sort by” for the category which is causing this issue.
So I logged into Magento BE, and used following path
Catalog >> Manage Categories >> Selected the category that raised the error >> Display Settings [TAB] >> Available Product Listing Sort by
Her I noticed that the new product attribute was not selected!!! Seems Simple, still…!!!

I am not sure if this error can also get triggered when we use default Toolbar.phtml without any modification.

Additional info:

Related to: A custom designed toolbar.phtml which was primarily used to modify list of sortby options.
Scenario: Error gets displayed when I click on a root category or when I try to use magento search.
Quick Solution: Make sure you have selected this new attribute in the list of “Available Product Listing Sort by” for the category that caused this error.

I am sure this might be rare case, but it can happen. Happy shopping!

Adding a new product attribute to magento and changing the default sort by option in magento

The magento screencast on adding a new product attribute is really what would give a clear idea on adding prodcut attribute.

Step 1: Follow the screencast and add new attribute

Step 2: Since you want this attribute to be used for sorting on list view, make sure the option “Used for sorting in product listing” is set to YES.

Step 3: Add the new attribute to the required attribute set.

Step 4: Go to System > configuration > Catalog > Catalog > Frontend

Step 5: Set the “Product listing sort by” option to the new field you added.

Click on the screenshot above for details.

That’s all, save the configuration, clear cache (if enabled) and relaod the list view. You should see the new attribute.

If you are using a custom template /package, chances are that you may have to change the code manually to view the new sort by field in the selection list.
The code is usually located in in catalog/product/list/toolbar.phtml

Felogin logout redirect does not work

When we try to logout from an access restricted page, we will see either a 404 (Page not found) or a 401 (Authorization required) error.
This issue seems quite old, but unfortunately there are still some bugs when we use the Logout template of the felogin.

The issue is reproduceable even on Typo3 4.2.8, I am not sure if this is fixed on 4.3 onwards.

There is a patch that we can use to patch felogin as given on the following URL:

Due to various reasons it may not always be possible to patch.
In such circumstances it is wiser to use an alternate technique, such as creating the Logout link manually.
One such example is:

[loginUser = *]  

lib.logoutbox = COA
lib.logoutbox {
    20 = TEXT
    20 {
       data = TSFE:fe_user|user|username
       # link to account edit page
       stdWrap.typolink.parameter = 60
    30 = IMAGE
    30 {
        file = fileadmin/templates/images/logout.gif
        stdWrap {
             # Let us link to home page for logging out
             typolink.parameter = 1
             typolink.additionalParams = &logintype=logout
             wrap =  |


In this example I am displaying the logged in username (which links to user account page) followed by a working logout button.

– Here we are not using the felogin plugin.
– Do not link the logout button to any access restricted page.

The following page from Typo3wizard might be useful for displaying more user-details if needed:

Dividers to Tabs in Extensions

This article explains how easily we can get Tabs in the content elements of type “insert records”.

Generally we will need to edit tca.php and ext_tables.php.

To be more specific it involves adding two parameters.

1. Specify that you are using dividers to tabs “dividersstabs”
2. Mark all tabs using –div–

Let us see how.

1. Specify that you are using dividers to tabs “dividersstabs”

In the TCA array first look at the start of table definition. Generally this is located


$TCA['tx_myext_table] = array ( 
        'ctrl' => array ( 
                'title' => 'LLL:EXT:myext/locallang_db.xml:tx_myext_table, 
                'label' => 'title', 
                'tstamp' => 'tstamp', 
                'crdate' => 'crdate', 
                'cruser_id' => 'cruser_id', 
                'languageField' => 'sys_language_uid', 
                'transOrigPointerField' => 'l10n_parent', 
                'transOrigDiffSourceField' => 'l10n_diffsource', 
                'sortby' => 'sorting', 
                'delete' => 'deleted', 
                'dividers2tabs' => TRUE, 
                'enablecolumns' => array ( 
                        'disabled' => 'hidden', 
                'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php', 
                'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'icon_tx_myext_table.gif', 


In the above config you can see that ‘dividers2tabs’ is set to TRUE

2. Mark all tabs using --div--

This is the step in which you would group all fields into different Tabs. This generally involves editing the TCA config usually locatd in tca.php.

In tca.php, look the section showitem, and add --div--;Tab Name,
'types' => array ( 
        '0' => array(
                'showitem' => '--div--;General,
                                sys_language_uid;;;;1-1-1, l10n_parent, 
                                l10n_diffsource, hidden;;1,
                                --div--;Content,title;;;;3-3-3, parentid,top_page,content,
                                --div--;Header and Footer,footer,

As you can see I have added 3 tabs, General, Content, Header and Footer.

The idea is to add --div--; (two hypen followed by div and two hyphen and semicolon)

After semicolon add the “Title of your tab” and followed by a comma.

This section --div--;Tab Name, must be added just before a field, or after a field ends.

That should be it.

Happy coding.