Magento Coding Solutions

magento to create SEO base URL pragmatically


Hear : "rushfee" is custom module;
we are create a custom link (SEO Link) like
 http://localhost/magento/rushfee/type/pingback/shape/round

$store_id=1;
$request_path = 'rushfee/type/pingback/shape/round' ;
$target_path='rushfee/index/index/type/pingback/shape/round';
$oUrlRewriteCollection = Mage::getModel('core/url_rewrite')->getCollection()->addFieldToFilter('target_path', $target_path); //check rewrite url exit or not
if(count($oUrlRewriteCollection)==0){
    echo "target path does exist";
 $rewriteModel = Mage::getModel('core/url_rewrite');
 $id_path =$target_path; //'rushfee/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();
}

you can get url data
echo $this->getRequest()->getParam('type');
echo $this->getRequest()->getParam('shape');

Use of $installer v $this in install scripts

$installer = $this;
you can uses instance of $this is 
$installer = new Mage_Eav_Model_Entity_Setup; 
or
$installer =new Mage_Catalog_Model_Resource_Setup;



$installer = new Mage_Sales_Model_Resource_Setup('core_setup');   
$installer->startSetup();

$installer->addAttribute("quote_address", "prepaiddiscount_total", array("type"=>"varchar"));
$installer->addAttribute("order", "prepaiddiscount_total", array("type"=>"varchar"));
$installer->endSetup();