How to get Magento layout outside of Magento

I integreated wordpress in my magento store and I will try to get magento data in wordpress file. I want to same header in my both site magento and wordpress. I tryed to hard and finally got the solution to get any magento layout in wordpress. Below are the script to

get magento layout outside of magento.

<?php
require_once '/home/.../public_html/.../app/Mage.php';
umask(0);
/* not Mage::run(); */
Mage::app('default');
 
// get layout object
$layout = Mage::getSingleton('core/layout');
 
//get block object
$block = $layout->createBlock('page/template_links');
 
/* choose whatever category ID you want */
//$block->setCategoryId(3);
$block->setTemplate('page/template/links.phtml');
 
echo $block->renderView();
?>

Listing sub-categories on a category page with category images.

This tutorial is going to show you one of the ways to list sub-categories on category pages of your Magento store. In order to display thumbnails of subcategories and their names on your category pages:
1:-In your Magento admin go to CMS -> Static Blocks
2:-Click “Add New Block” at the top right.
3:-Create a new static block as follows:
Block Title: Sub Category Listing
Identifier: subcategory_listing
Status: Enabled
Content:
{{block type="catalog/navigation" template="catalog/navigation/subcategory_listing.phtml"}}

How to Create a block in Magento


Many time we need to create a new block in Magento sites.There are two types of Block in Magento:-
1. Structural Blocks
2.Content Blocks For more detail see here.
Step 1 :- Now we are going to create a new Structural Blocks for this you have to create a new file local.xml in your them's layout folder and put this code:-
<?xml version="1.0"?>

  
 
 
   
    
   
  
    

How to modify/change shpping price in Magento


If you want modify or change Shipping price in Magento then we can do it using Observer So let's see how to do it:- We are going to create a Custom Module for it.
Step 1:- So let's create a config file Arunendra_Extrashipcost.xml in app/etc/modules put following code in this file:-

<?xml version="1.0"?>



    
        true
        local
    


Step 2:- create following folder and file under app/code/local
1:-Arunendra/Extrashipcost/etc/config.xml
2:-Arunendra/Extrashipcost/etc/Model/Observer.php
Step 3:-Put following code in config.xml file:-

<?xml version="1.0"?>


  

    
      0.1.0
    
  
	
		
            
            Arunendra_Extrashipcost_Model
            
		
	
 
	
		
			
				
					singleton
					extrashipcost/observer
					salesQuoteCollectTotalsBefore
				
			
		
	

 
Step 4:-Put following code in Observer.php file:-
<?php
class Arunendra_Extrashipcost_Model_Observer
{
 public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer)
    {
         $quote = $observer->getQuote();        
	    $store    = Mage::app()->getStore($quote->getStoreId());
        $carriers = Mage::getStoreConfig('carriers', $store);     
		$newFee = 	floatval($carriers['flatrate']['price'] * 0.15);
        foreach ($carriers as $carrierCode => $carrierConfig) {
            if($carrierCode == 'flatrate'){          
			
                    Mage::log('Handling Fee(Before):' . $store->getConfig("carriers/{$carrierCode}/handling_fee"), null, 'shipping-price.log');
                    $store->setConfig("carriers/{$carrierCode}/handling_type", 'F'); #F - Fixed, P - Percentage                 
                    $store->setConfig("carriers/{$carrierCode}/handling_fee", $newFee);     
                    ###If you want to set the price instead of handling fee you can simply use as:
                    #$store->setConfig("carriers/{$carrierCode}/price", $newPrice);     
                    Mage::log('Handling Fee(After):' . $store->getConfig("carriers/{$carrierCode}/handling_fee"), null, 'shipping-price.log');
            
            }
        }
    }
}
?>

how to add a custom column in Magento sales/order grid


Step 1 :- Copy app\code\core\Mage\Adminhtml\Block\Sales\Order\grid.php
to
app\code\local\Mage\Adminhtml\Block\Sales\Order\grid.php now Find _prepareColumns() function to Add column use this code:-
$this->addColumn('color ', array(
    'header' => Mage::helper('sales')->__('color #'),
    'index' => 'color',
    'sortable'  => false,
    'filter'    => false,
    'renderer' => 'Mage_Adminhtml_Block_Sales_Order_Renderer_Productatt',
));
Step 2:- Create a new file at :-
app\code\local\Mage\Adminhtml\Block\Sales\Order\Renderer\Productatt.php add this code :-
<?php
class Mage_Adminhtml_Block_Sales_Order_Renderer_Productatt extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    public function render(Varien_Object $row)
    {                    

         $order = Mage::getModel('sales/order')->load($row->getData('entity_id'));              
            $attribute ="";

        foreach($order->getAllVisibleItems() as $_item){  
        $product    =   Mage::getModel('catalog/product')->load($_item->getProductId());         
       if($product->getAttributeText('color')){
            $attribute .= $product->getAttributeText('color');
       }
    }
        unset($order);
        return $attribute;      
    }       
}
?>