在Magento shell脚本中使用getUrl

pac*_*eau 4 shell magento

我已经customscript.php/shelldir中创建了一个脚本.此脚本扩展Mage_Shell_Abstract.

当我getUrl()在这个脚本中使用时,Magento会customscript.php在URL中添加.

如果我做:

Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id' => 123));
Run Code Online (Sandbox Code Playgroud)

我有:

http://mysite.com/customscript.php/admin/sales_order/view/order_id/123/key/{secret key}
Run Code Online (Sandbox Code Playgroud)

如何customscript.php在不使用str_replace()结果的情况下从URL中删除?

小智 9

你可以使用'_type'参数为getUrl()函数,如下所示:

Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array(
  'order_id' => 123,
  '_type' => Mage_Core_Model_Store::URL_TYPE_WEB
));
Run Code Online (Sandbox Code Playgroud)