Magento – Product related code

1.    How to display New products on Home page?

For displaying new products on Home page go to
“CMS -> Manage Pages” and select “Home page” from the list of pages.
Add following line of code in it

{{block type=”catalog/product_new” name=”home.catalog.product.new”
alias=”product_homepage” template=”catalog/product/new.phtml”}}

————————————————————————————————————————————————–

2.  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

————————————————————————————————————————————————–

3.   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

————————————————————————————————————————————————–

4. Exception printing is disabled by default for security reasons  Erro in Magento :

If you face any issue like as below Issue:

Exception printing is disabled by default for security reasons
Error log record number: *********
here has been an error processing your request
Solution :
In this case we need to check following steps.
Step 1 : Go to folder /errors/
Step 2 : Change local.xml.sample to local.xml
Step 3 : after this change you can see few more errors.
then Open magento/lib/Zend/Cache/Backend/File.php
and search
From
protected $_options = array(
‘cache_dir’ => ‘null’,
To
protected $_options = array(
‘cache_dir’ => ‘tmp/’,
Save the changes.
Step 4 : create tmp folder under root magento folder.