Magento fixing error params['general[path]'] is undefined

Posted by Damodar Bashyal on June 21, 2012

 

After I imported categories using unirgy's uRapidFlow, I was unable to edit categories as i was getting error "params['general[path]'] is undefined" on my firebug console.

After going through magento forums I found this fix:

goto: app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml and update:

var path = params['general[path]'].split('/');  

to:

var path = url.split('/');

But I override the form.phtml and updated like this:

create file: app\code\community\Technooze\Tadminhtml\Block\Page.php and add below code: (admin didn't pickup custom theme, so, had to rewrite the block)

<?php
class Technooze_Tadminhtml_Block_Page extends Mage_Adminhtml_Block_Page
{
   /**
    * Class constructor
    *
    */
    public function __construct()
    {
        Mage_Adminhtml_Block_Template::__construct();
        Mage::getDesign()->setTheme('technooze');
        
        $this->setTemplate('page.phtml');
        $action = Mage::app()->getFrontController()->getAction();
        if ($action) {
            $this->addBodyClass($action->getFullActionName('-'));
        }
    }
}

create file: app\code\community\Technooze\Tadminhtml\etc\config.xml and add below code:

<?xml version="1.0"?>
<config>
    <modules>
        <Technooze_Tadminhtml>
            <version>0.1.0</version>
        </Technooze_Tadminhtml>
    </modules>
    <global>
        <blocks>
            <tadminhtml>
                <class>Technooze_Tadminhtml_Block</class>
            </tadminhtml>
            <adminhtml>
                <rewrite>
                    <page>Technooze_Tadminhtml_Block_Page</page>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

Then, create file: app\etc\modules\Technooze_All.xml and add this:

<?xml version="1.0"?>
<config>
    <modules>
        <Technooze_Tadminhtml>
            <active>true</active>
            <codePool>community</codePool>
        </Technooze_Tadminhtml>
    </modules>
</config>

Now, copy file: app\design\adminhtml\default\default\template\catalog\category\edit\form.phtml

to: app\design\adminhtml\default\technooze\template\catalog\category\edit\form.phtml

Search for:

var path = params['general[path]'].split('/');

just before that line add this:

var catPath = '<?php
    $categoryId = Mage::app()->getRequest()->getParam('id');
    if(!$categoryId){
        $parentId = Mage::app()->getRequest()->getParam('parent');
        $categoryId = ($parentId ? $parentId : '0');
    }
    $categoryId = ($categoryId ? $categoryId : Mage::app()->getWebsite(true)->getDefaultStore()->getRootCategoryId());
    $category = Mage::getModel('catalog/category')->load($categoryId);
    echo $category->getPath();
?>';
params['general[path]'] = params['general[path]'] ? params['general[path]'] : catPath;

After that update i was able to work with categories again as params['general[path]'] was never undefined again.

Not sure if there is any easier method to fix this but that helped me learn something new in magento.

 
not published on website


QR Code: Magento fixing error params['general[path]'] is undefined