Magento + Wordpress集成问题

时间:2013-05-23 06:47:00

标签: wordpress magento

<page>
            <rewrite>
                <html>MageWorx_SeoSuite_Block_Page_Html</html>
                <html_head>MageWorx_SeoSuite_Block_Page_Html_Head</html_head>
            </rewrite>
        </page>

上面的代码重写了该块。 我正在使用以下代码创建一个新的标题块,然后手动将JS文件添加到我的wordpress博客中的标题块,以保持页眉和页脚与Magento相同

$layout = Mage::getSingleton('core/layout'); 
$headBlock = $layout->createBlock('page/html_head');
$headBlock->addJs('prototype/prototype.js');
..... and other JS and CSS using the same code

但是,当我使用上面的代码时,它给我带来了像

这样的错误
"Call to a member function getFullActionName() on a non-object in app\code\local\MageWorx\SeoSuite\Block\Page\Html\Head.php on line 53" 

第53行是

        $actionName = $this->getAction()->getFullActionName();

扩展Mageworx_seosuite在Magento中运行正常,没有任何错误,但是当我尝试在博客中按照http://www.atwix.com/magento/wordpress-magento/

使用它时,它会出错

任何人都可以帮我解决这里的错误。

由于

1 个答案:

答案 0 :(得分:0)

由于Magento文件包含在Wordpress中,因此没有实际的Magento请求正在运行,因此没有前端控制器,MageWorx扩展通常是正确依赖的。

您可以尝试做的是通过在$headBlock创建后添加此代码来强制存在虚拟前端控制器:

if ($headBlock instanceof MageWorx_SeoSuite_Block_Page_Html_Head) {
    $reflectedApp = new ReflectionObject(Mage::app());
    $controllerProperty = $reflectedApp->getProperty('_frontController');
    $controllerProperty->setAccessible(true);
    $controllerProperty->setValue(Mage::app(), new Mage_Core_Controller_Varien_Front());
    new Mage_Core_Controller_Front_Action(Mage::app()->getRequest(), Mage::app()->getResponse());
}

但这不是很干净,可能还不够。

或者,您可以尝试在创建块之前禁用MageWorx重写:

Mage::app()->getConfig()->setNode('global/blocks/page/rewrite/html_head', '', true);