【问题标题】:Wrong tab configuration on MagentoMagento 上的选项卡配置错误
【发布时间】:2012-01-09 16:50:47
【问题描述】:

我开发的一个 magento 扩展存在很大问题。本地主机一切都很好,但是当我部署时,它得到了这个错误。

选项卡配置错误

#0 [internal function]: Mage_Adminhtml_Block_Widget_Tabs->addTab('pricematrix', 'tab_pricematrix')
#1 /var/www/vhosts/discountprint.dk/httpdocs/app/code/core/Mage/Core/Model/Layout.php(347): call_user_func_array(Array, Array)
#2 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Model/Layout.php(213): Mage_Core_Model_Layout->_generateAction(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#3 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Model/Layout.php(209): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#4 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(343): Mage_Core_Model_Layout->generateBlocks()
#5 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(270): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#6 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Adminhtml/Controller/Action.php(263): Mage_Core_Controller_Varien_Action->loadLayout(Array, true, true)
#7 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(246): Mage_Adminhtml_Controller_Action->loadLayout(Array)
#8 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_ProductController->editAction()
#9 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch('edit')
#10 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /var/www/vhosts/something.dk/httpdocs/app/code/core/Mage/Core/Model/App.php(340): Mage_Core_Controller_Varien_Front->dispatch()
#12 /var/www/vhosts/something.dk/httpdocs/app/Mage.php(627): Mage_Core_Model_App->run(Array)
#13 /var/www/vhosts/something.dk/httpdocs/index.php(80): Mage::run('', 'store')
#14 {main}

我用 Google 搜索了几个小时,但找不到任何有用的信息。我的magento版本是1.5.0.1

希望你能帮忙

【问题讨论】:

  • 如果有人能指出可能出现错误的方向,那就太好了。
  • 顺便说一句,本地主机运行的是更新版本 1.5.1.0
  • 错误信息本身是什么?
  • 想在这里添加评论。如果它是您开发的扩展,请检查您在 adminhtml.xml 中是否正确设置了模块名称。当我在 acl xml module="smartstock" 中有拼写错误时,我遇到了同样的问题,它应该是 module="smart_stock">

标签: magento-1.5 magento


【解决方案1】:

如果您停止在 Google 上搜索并开始搜索您的代码,您将获得更多。

搜索异常字符串“错误的选项卡配置”

$ ack 'Wrong tab configuration'
Adminhtml/Block/Widget/Tabs.php
108:                throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
112:            throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));

看,整个源代码树中只有 两个 可能的位置可能会引发该异常,无论是在您的堆栈跟踪指示正在调用的 addTab 方法中。在上下文中查看该代码

public function addTab($tabId, $tab)
{
    if (is_array($tab)) {
        $this->_tabs[$tabId] = new Varien_Object($tab);
    }
    elseif ($tab instanceof Varien_Object) {
        $this->_tabs[$tabId] = $tab;
        if (!$this->_tabs[$tabId]->hasTabId()) {
            $this->_tabs[$tabId]->setTabId($tabId);
        }
    }
    elseif (is_string($tab)) {
        if (strpos($tab, '/')) {
            $this->_tabs[$tabId] = $this->getLayout()->createBlock($tab);
        }
        elseif ($this->getChild($tab)) {
            $this->_tabs[$tabId] = $this->getChild($tab);
        }
        else {
            $this->_tabs[$tabId] = null;
        }

        if (!($this->_tabs[$tabId] instanceof Mage_Adminhtml_Block_Widget_Tab_Interface)) {
            throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
        }
    }
    else {
        throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
    }

看起来您的呼叫正在通过第二个 if/else 分支。您的标签字符串 tab_pricematrix 用于从当前标签中获取子块

$this->_tabs[$tabId] = $this->getChild($tab);

但是,它看起来在那里找到的任何东西不是Mage_Adminhtml_Block_Widget_Tab_Interface 的子代。

我的猜测是因为对 getChild 的调用返回 false,因为您的模块没有在布局中添加名称为 tab_pricematrix 的选项卡(您是否将布局 XML 文件复制到新服务器?)没有知道您是如何实现该模块的,因此无法确定。

祝你好运!

【讨论】:

  • 我正在删除不再使用的扩展文件,这个答案帮助了我。我做了一个
    grep -rin "tab_pricematrix" * 并找到了有问题的文件。 (我的函数不叫 tab_pricematrix)事实证明,开发人员编写了自定义覆盖来解除扩展依赖项,当删除未使用的包时,扩展依赖项会被破坏。
【解决方案2】:

通常不会出现在实时站点上的本地主机问题与文件系统区分大小写有关。根据我的经验,大多数开发人员在 Windows / Mac OSX 上开发,默认情况下不区分大小写。但是大多数生产环境都是某种 *nix 系统。过去让我感到困惑的一件事是文件名中间有一个大写字母。

例如,如果一个块是 FooBar.php 并且位于 Mage_Core 中,那么在加载模型时您必须使用...

Mage::getModel('core/fooBar');

字符串会自动通过 ucwords 运行,但显然在请求模型/块等时需要考虑文件命名中的任何驼峰式大小写。

【讨论】:

  • 你的例子中 foo 和一个小 f 是错字吗?
  • 不,路径 get 的下划线爆炸,并贯穿 ucwords,这意味着 f 将自动变为大写。如果该类改为 Foo_Bar,并且是一个名为 Bar.php 的文件,位于 Foo 文件夹中,则可以简单地使用 'core/foo_bar'。
猜你喜欢
  • 1970-01-01
  • 2011-09-15
  • 1970-01-01
  • 2015-09-09
  • 2020-10-15
  • 2021-10-30
  • 2020-08-01
  • 2016-09-12
  • 1970-01-01
相关资源
最近更新 更多