Magento在线客户上次重写URL

时间:2012-08-24 02:02:28

标签: magento url-rewriting

我正在运行Magento CE 1.6.2.0。

Magento的在线客户功能非常棒。唯一的问题是“最后一个URL”列可能通过显示重写(如果存在)更有帮助。

我改变了app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Url.php

public function render(Varien_Object $row)
{
    return htmlspecialchars($row->getData($this->getColumn()->getIndex()));
}

到此:

public function render(Varien_Object $row)
{
    $lastUrl = htmlspecialchars($row->getData($this->getColumn()->getIndex()));

    $lastUrlRewrite = Mage::getModel('core/url_rewrite')
        ->setStoreId(1)
        ->loadByRequestPath($lastUrl);

    $url = ($lastUrlRewrite) ? $lastUrlRewrite : $lastUrl;

    return $url;
}

StoreId是正确的,但输出仍为空。

任何帮助将不胜感激!谢谢。

1 个答案:

答案 0 :(得分:0)

loadByRequestPath()方法返回Mage_Core_Model_Url_Rewrite对象,而不是字符串。你可能想这样做:

 $url = ($lastUrlRewrite->getId()) ? $lastUrlRewrite->getTargetPath() : $lastUrl;