Magento: Noindex Nofollow CMS page

Add following code on CMS->Page ->Edit Page ->Design->Layout update xml

<reference name="head">
<action method="setRobots"><value>NOINDEX,FOLLOW</value></action>
</reference>

Advertisements

Magento create invoice programmatically

$order_id = 1;
 $order = Mage::getModel("sales/order")->load($order_id);

try {

if(!$order->canInvoice())
 {
 Mage::throwException(Mage::helper('core')->__('Cannot create an invoice...'));
 }

$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();

if (!$invoice->getTotalQty()) {
 Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
 }

$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::NOT_CAPTURE);

$invoice->register();
 $transactionSave = Mage::getModel('core/resource_transaction')
 ->addObject($invoice)
 ->addObject($invoice->getOrder());

$transactionSave->save();

}
 catch (Mage_Core_Exception $e) {
 echo $e->getMessage();
 }

Magento get controller / module / action / cms page name

/* get Controller/module/action name */

$controller = Mage::app()->getRequest()->getControllerName();
$module = Mage::app()->getRequest()->getModuleName();
$action = Mage::app()->getRequest()->getActionName();
$layout = $this->getLayout()->getBlock('root')->getTemplate();

/* get page name/indentifier */

$pageTitle = Mage::getSingleton('cms/page')->getIdentifier(); 
$pageTitle = Mage::getModel('cms/page')->load('about-page', 'identifier')->getTitle();

/* Magento get front controller name */

$frontController = Mage::app()->getFrontController()->getRequest()->getRouteName();