Magento Code Snippet

It may help, for you doubt

1.How to show 4 products instead of 3 products in a row on Listing Page in Magento Theme?

To show 4 products instead of 3 on listing page in Magento Theme you need to edit app/design/frontend/default/Your_Theme/template/catalog/product/list.phtml file and just add the following line
$this->setData(‘column_count’,4);
after below code
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper(‘catalog/output’);
?>
Add another one line,Ex : Code like this
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper(‘catalog/output’);
$this->setData(‘column_count’,4);
?>

2. How to get the customer’s shipping address in Magento?

$customerAddressId = Mage::getSingleton(‘customer/session’)->getCustomer()->getDefaultShipping();
if ($customerAddressId)
{
$address = Mage::getModel(‘customer/address’)->load($customerAddressId);
}

3. How to show cart quantity and total price in header?

To show cart quantity and total price add the following code to
app/design/frontend/default/[Your Theme]/template/page/html/header.phtml
<a href=”<?php echo $this->getUrl(”).”checkout/cart/”;?>” >Your Basket<strong>(<?php if(Mage::helper(‘checkout/cart’)->getSummaryCount() > 0) { echo Mage::helper(‘checkout/cart’)->getSummaryCount(); } else { echo “0”; }?>)</strong> Total: <?php echo $this->helper(‘checkout’)->formatPrice(Mage::getSingleton(‘checkout/cart’)->getQuote()->getGrandTotal()); ?>
<?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>
(<?php echo Mage::helper(‘checkout’)->formatPrice($_subtotalInclTax) ?><?php echo Mage::helper(‘tax’)->getIncExcText(true) ?>)
<?php endif; ?>
Sample Output :  Your Basket(0) Total: $0.00

4. How to add social links on Product page in Magento?

<a title=”Share on Facebook” href=”http://www.facebook.com/sharer.php?u=getProductUrl() ?&gt;&amp;t=Check+this+out” target=”_blank”><img src=”&lt;?php echo $this-&gt;getSkinUrl(”) ?&gt;/images/YOUR IMAGE” alt=”Share on Facebook” />
</a><a title=”Send to Twitter!” href=”http://twitter.com/home?status=Check out the &lt;?php echo $this-&gt;htmlEscape($_product-&gt;getName()) ?&gt; at &lt;?php echo $_product-&gt;getProductUrl() ?&gt; @ SITENAME” target=”_blank”><img src=”&lt;?php echo $this-&gt;getSkinUrl(”) ?&gt;/images/icons/YOUR IMAGE” alt=”Follow us on Twitter” /></a>
app\design\frontend\base\default\template\catalog\product\view.phtml