phpshellmagento

using getUrl in a Magento shell script


I've created a script named customscript.php in the /shell dir. This script extends Mage_Shell_Abstract.

When I use getUrl() inside this script, Magento adds customscript.php in the URL.

If I do:

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

I have:

http://mysite.com/customscript.php/admin/sales_order/view/order_id/123/key/{secret key}

How can I remove customscript.php from the URL without using str_replace() the result?


Solution

  • you can use '_type' param for getUrl() function as follows:

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