Magento lets you get url with or without parameters as below:
// get base url Mage::getUrl() // http://dltr.org/
// get base url and index.html page
Mage::getUrl('index.html')
// http://dltr.org/index.html
// get brands page with id parameter
Mage::getUrl('brands/brand', array('id' => 1));
// http://dltr.org/brands/brand/id/1
// get secure url
Mage::getUrl('brands/brand', array('id' => 1,'_secure' => true));
// https://dltr.org/brands/brand/id/1
// or get secure url based on current page. good for ajax urls.
Mage::getUrl('brands/brand', array('id' => 1,'_secure' => Mage::app()->getStore()->isCurrentlySecure()));
// http(s)?://dltr.org/brands/brand/id/1
But i used this code not working
when add magento "rewrite" then working propely
You can use Below code
$store_id=1;
$request_path = 'designeruser/id/2/' ;
$target_path='designeruser/index/index/id/2';
$oUrlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()->addFieldToFilter('target_path', $target_path);
if(count($oUrlRewriteCollection)==0){
echo "target path does exist";
$rewriteModel = Mage::getModel('core/url_rewrite');
$id_path ='designeruser/index/index/id/2';
$rewriteModel->setData('request_path', $request_path);
$rewriteModel->setData('target_path', $target_path);
$rewriteModel->setData('id_path',$id_path);
$rewriteModel->setOptions('RP');
$rewriteModel->setData('store_id', $store_id);
$rewriteModel->setData('is_system', 0);
$rewriteModel->save();
}
No comments:
Post a Comment