我的网上商店在安装新主题后破了,但是在将主题更改回默认值后错误仍然存在。
Notice: Undefined index: catalog.topnav in /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php on line 460
#0 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(460): mageCoreErrorHandler(8, 'Undefined index...', '/home/havhokere...', 460, Array)
#1 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('page/html_topme...', 'catalog.topnav')
#2 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('page/html_topme...', 'catalog.topnav')
#3 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#4 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(206): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#5 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(206): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#6 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(206): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#7 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#8 /home/havhokeren/public_html/magento/app/code/core/Mage/Cms/Helper/Page.php(113): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#9 /home/havhokeren/public_html/magento/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')
#11 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Cms_IndexController->indexAction()
#12 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#13 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#14 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#15 /home/havhokeren/public_html/magento/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#16 /home/havhokeren/public_html/magento/index.php(89): Mage::run('', 'store')
#17 {main}
我不知道是什么导致这个,我在管理面板中安装主题后遇到的另一个错误,如果我点击“类别”我会收到此错误:
Notice: Undefined offset: 0 in /home/havhokeren/public_html/magento/app/design/adminhtml/default/default/template/cmsmart/megamenu/menutop.phtml on line 85
#0 /home/havhokeren/public_html/magento/app/design/adminhtml/default/default/template/cmsmart/megamenu/menutop.phtml(85): mageCoreErrorHandler(8, 'Undefined offse...', '/home/havhokere...', 85, Array)
#1 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Block/Template.php(241): include('/home/havhokere...')
#2 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#3 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#4 /home/havhokeren/public_html/magento/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#5 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#6 /home/havhokeren/public_html/magento/app/code/local/Cmsmart/Megamenu/Block/Catalog/Category/Tabs.php(174): Mage_Core_Block_Abstract->toHtml()
#7 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Block/Abstract.php(293): Cmsmart_Megamenu_Block_Catalog_Category_Tabs->_prepareLayout()
#8 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#9 /home/havhokeren/public_html/magento/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php(55): Mage_Core_Model_Layout->createBlock('adminhtml/catal...', 'tabs')
#10 /hom e/havhokeren/public_html/magento/app/code/core/Mage/Core/Block/Abstract.php(293): Mage_Adminhtml_Block_Catalog_Category_Edit_Form->_prepareLayout()
#11 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#12 /home/havhokeren/public_html/magento/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php(82): Mage_Core_Model_Layout->createBlock('adminhtml/catal...')
#13 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Block/Abstract.php(293): Mage_Adminhtml_Block_Widget_Form_Container->_prepareLayout()
#14 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#15 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('adminhtml/catal...', 'category.edit')
#16 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('adminhtml/catal...', 'category.edit')
#17 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#18 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#19 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#20 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#21 /home/havhokeren/public_html/magento/app/code/core/Mage/Adminhtml/Controller/Action.php(275): Mage_Core_Controller_Varien_Action->loadLayout(NULL, true, true)
#22 /home/havhokeren/public_html/magento/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php(201): Mage_Adminhtml_Controller_Action->loadLayout()
#23 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_CategoryController->editAction()
#24 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('edit')
#25 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#26 /home/havhokeren/public_html/magento/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#27 /home/havhokeren/public_html/magento/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#28 /home/havhokeren/public_html/magento/index.php(89): Mage::run('', 'store')
#29 {main}
非常感谢任何帮助。
Magento版本:1.9.1.1
网站:www.havhokeren.dk/magento
答案 0 :(得分:0)
永远不要假设存在变量。如果提供商没有提供正确的值,情况可能会发生变化。
由于缓存,您可能很幸运,之前没有弹出错误。
在menutop,你有85号线
if($categoryArr[0]['active_product']== 1)
这些是您的代码所做的假设:
这是很多假设。
为了使其更具防弹性,理想情况下,您可以使用辅助函数来访问具有故障保护默认值的数组,或使用复杂的if语句
if(!is_null($categoryArr) && is_array($categoryArr) && array_key_exists(0,$categoryArr) && !is_null($categoryArr[0]) && is_array($categoryArr[0]) && array_key_exist('active_product', $categoryArr[0]) ){
或您使用辅助功能
function getValue($key, $arr, $default=null) {
$pieces = explode('.', $key);
$array = $arr;
foreach($pieces as $array_key) {
if(!is_null($array) && is_array($array) && array_key_exists($array_key, $array)) {
$array = $array[$array_key];
}
else {
$array = null;
break;
}
}
return is_null($array) ? $default : $array;
}
$testarr = [
['foobar' => 'baz'],
['active' => false]
];
$output = getValue('0.foobar',$testarr,'NOT FOUND');
var_dump($output);
$output = getValue('0',$testarr,'NOT FOUND');
var_dump($output);
$output = getValue('1.active',$testarr,'NOT FOUND');
var_dump($output);
$output = getValue('i.do.not.exist',$testarr,'NOT FOUND');
var_dump($output);