Magento – Reset customer Password is blank in email

After Magento 1.9 version due to security reason password field send empty.
and the variable are not set for :

{{htmlescape var=$customer.password}}

From updates Magento 1.6 to 1.9 version was change to change the forgot password email. In previous versions, the temporary password was sent in the email, but now in latest uses a reset link instead. If you have a custom template for the forgot password email or magento theme, and that was not updated, the password sent set to blank.

Solution is create a new template for reset password link.

1. Go to System > Transactional Mails
2. Edit default template: Remind Password
3. The template details should appear in the fields when you click on Edit Template or create new template.
4. Edit template content, add:

If you requested this password change, please click on the following link to reset your password:

{{store url=”customer/account/resetpassword/” _query_id=$ _query_token=$customer.rp_token}}

If clicking the link does not work, please copy and paste the URL into your browser instead.

5. Save

6. Set forgot password to use this template.

7. Go to System > Configuration > Customer Configuration > Password Options and update Forgot Email Template to the template you just created.

Storing the state in a cookie with local storage jQuery Datatables Search, paging and filter ?

$(document).ready(function() {
$(‘#example’).dataTable( {
“bStateSave”: true,
“fnStateSave”: function (oSettings, oData) {
localStorage.setItem( ‘DataTables’, JSON.stringify(oData) );
“fnStateLoad”: function (oSettings) {
return JSON.parse( localStorage.getItem(‘DataTables’) );
} );
} );



Automatically Complete WooCommerce Orders for virtual product or downloadable products

When a WooCommerce order is placed, the customer will pay for it, the order will be fulfilled and the item(s) dispatched, at which point the order will probably be marked as ‘Completed’.

This process is supported in WooCommerce and allows the order to go from ‘Pending’, to ‘Processing’, and finally to ‘Completed’ once the products have been sent out.

Please add this code to theme’s functions.php file.

* Auto Complete all WooCommerce orders.
* Add to theme functions.php file

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
    global $woocommerce;
    if ( !$order_id )
    $order = new WC_Order( $order_id );
       $virtual_order = null;
    if ( count( $order->get_items() ) > 0 ) {
      foreach( $order->get_items() as $item ) {
        if ( 'line_item' == $item['type'] ) {
          $_product = $order->get_product_from_item( $item );
          if ( ! $_product->is_virtual() ) {
            // once we've found one non-virtual product we know we're done, break out of the loop
            $virtual_order = false;
          } else {
            $virtual_order = true;
    // virtual order, mark as completed
    if ( $virtual_order ) {
       $order->update_status( 'completed' );

How can create custom sidebar category menu for AW Blog

1. Create a menu_cat.phtml file in app\design\frontend\default\default\template\aw_blog

<div class=”block block-blog”>
<div class=”block-title”>
<strong><span><?php echo Mage::getStoreConfig(‘blog/blog/title’); ?></span></strong>
<div class=”block-content”>


$collection = Mage::getModel(‘blog/cat’)
->setOrder(‘sort_order’, ‘asc’)
$home_url = Mage::helper(‘core/url’)->getHomeUrl();
<?php if ($collection->count() ): ?>
<div class=”menu-categories”>
<h5><?php echo Mage::helper(‘blog’)->__(‘Categories’); ?></h5>
<?php  foreach ($collection as $item) : ?>
<li><a href=”<?php echo $home_url.’blog/cat/’.$item[‘identifier’]; ?>” ><?php echo $item[‘title’]; ?></a></li>
<?php endforeach; ?>
<?php endif; ?>


2. Create a static block from admin side and a following code in content.

<p>{{block type=”blog/blog” template=”aw_blog/menu_cat.phtml”}}</p>

3. Put below code in 2columns-right.phtml or 2columns-left.phtml


echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘block_identifier_name’)->toHtml();


How to get Current Page URL, Module, Controller and Action Name, CMS Page URL and Current Skin URL in Magento


Mage::app()->getFrontController()->getRequest()->getModuleName();  //Get Current Module Name
Mage::getSingleton(‘cms/page’)->getIdentifier();  // Get Current CMS page
Mage::app()->getFrontController()->getRequest()->getRouteName();  // Get Route Name
Mage::getSingleton(‘cms/page’)->getIdentifier();  // Get Identifier Name

Mage::getDesign()->getSkinUrl(); // Get Current Skin URL

Magento New arrival product

Magento New arrival product

Create newarrival.phtml file and put it here :


$storeId = Mage::app()->getStore()->getId();
$collection =  Mage::getResourceModel(‘catalog/product_collection’)
->addAttributeToSelect(‘*’) // select all attributes
->addAttributeToSort(‘entity_id’, ‘DESC’) // sorting
->addAttributeToFilter(‘status’, array(‘eq’ => Mage_Catalog_Model_Product_Status::STATUS_ENABLED))// status
->setPageSize(80); // for limit


<?php if(!$collection->count()): ?>
<p><?php echo $this->__(‘There are no products matching the selection.’) ?></p>
<?php else: ?>
<div style=”margin:0 15px;”>
<ul id=”newarrival”>
<?php // Grid Mode ?>
<?php $_collectionSize = $collection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0;
foreach ($collection as $_product):
//$obj = Mage::getModel(‘catalog/product’);
//$productid = $product[‘entity_id’];
//$_product = $obj->load($productid);
<?php if ($i++%$_columnCount==0): ?>
<input type=”hidden” id=”prd” value=”<?php print  Mage::getSingleton(‘core/session’)->getMyValue(); ?>”  />
<li style=”margin-right:5px;”>
<a href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->htmlEscape($this->getImageLabel($_product, ‘small_image’)) ?>”><img src=”<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(150,150); ?>” width=”150″ height=”150″ alt=”<?php echo $this->htmlEscape($this->getImageLabel($_product, ‘small_image’))?>” /><span>&nbsp;</span></a>
<h2><?php //print Mage::getSingleton(‘core/session’)->getMyValue(); ?><a href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->htmlEscape($_product->getName()) ?>”><?php echo $this->htmlEscape(substr($_product->getName(),0,20)) ?></a></h2>
<?php endif ?>
endforeach ?>
<!–   <script type=”text/javascript”>decorateGeneric($$(‘ul.tabs-products-grid’), [‘odd’,’even’,’first’,’last’])</script>–>
<?php endif; ?>

Now put this line where you want to view best selling products..

you can use through block or through XML also

{{block type=”catalog/product_popular” template=”catalog/product/newarrival.phtml”}}

Magento Best Selling or Top Selling Product

Magento Best Selling or Top Selling Product

Here, we have written article about How to display Best Selling or Top Selling Product in Magento?. To show Best selling or Top selling Product at Home page. So that Best products should come on home page.

For that follow the following steps:

Create a Bestseller.php file and put it here :

class Mage_Catalog_Block_Product_Bestseller extends Mage_Catalog_Block_Product_Abstract{
public function __construct(){
$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel(‘reports/product_collection’)
->addAttributeToSelect(array(‘name’, ‘price’, ‘small_image’))
->setOrder(‘ordered_qty’, ‘desc’); // most best sellers on top

Create bestseller.phtml file and put it here :



$_products = $this->getProductCollection();
Mage::getSingleton(‘cataloginventory/stock’)->addInStockFilterToCollection($_products); // for qty stock check

for print Query

//echo $_products->getSelect();
//print $_products->getSize();

if ($_products->getSize()): : ?>
<?php $i=0; foreach ($_products->getItems() as $_product): ?>
<?php if ($i>5): continue; endif; ?>
<a href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->htmlEscape($_product->getName()) ?>”>
<img src=”<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(65,65); ?>” alt=”<?php echo $this->htmlEscape($_product->getName()) ?>”/>
<?php echo $_product->getDescription(); //also getShortDescription ?>
<p><a href=”<?php echo $_product->getProductUrl() ?>” title=”<?php echo $this->htmlEscape($_product->getName()) ?>)”><?php echo $_product->getName() ?></a></p>
<?php //echo $this->helper(‘review/product’)->getSummaryHtml($_product, ‘short’) //product review link ?>
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
<?php //echo $this->helper(‘catalog/product’)->getPriceHtml($_product) ?>
<?php echo $this->getPriceHtml($_product) ?>
<?php echo $_product->getProductId(); ?>
<?php if($_product->getevent_date()) {echo $_product->getevent_date();} ?>
<?php $i++; endforeach; ?>
<?php for($i;$i%5!=0;$i++): ?>
<?php endfor ?>
<?php endif; ?>

Now put this line where you want to view best selling products..

you can use through block or through XML also

{{block type=”catalog/product_bestseller” template=”catalog/product/bestseller.phtml”}}

date difference or count day or month or year between two dates in php

If you have a get a date difference between two dates like 2 days left or 1 month left count from current date to start date than it code is useful for you..


$date2 = date(“d-m-Y H:i:s”,strtotime($row[‘end_date_time’]));
// where $row[‘end_date_time’] is your start data
$date1 = date(“d-m-Y H:i:s”,strtotime(date(‘Y-m-d H:i:s’)));

$diff = abs(strtotime($date2) – strtotime($date1));

$years   = floor($diff / (365*60*60*24));
$months  = floor(($diff –
$years * 365*60*60*24) / (30*60*60*24));
$days    = floor(($diff –
$years * 365*60*60*24 – $months*30*60*60*24)/ (60*60*24));
$hours   =
floor(($diff – $years * 365*60*60*24 – $months*30*60*60*24 –
$days*60*60*24)/ (60*60));
$minuts  = floor(($diff – $years *
365*60*60*24 – $months*30*60*60*24 – $days*60*60*24 – $hours*60*60)/
60);  $seconds = floor(($diff – $years * 365*60*60*24 –
$months*30*60*60*24 – $days*60*60*24 – $hours*60*60 – $minuts*60));

printf(“%d years, %d months, %d days, %d hours, %d minuts\n, %d
seconds\n”, $years, $months, $days, $hours, $minuts, $seconds);


google map with calculate between more than two places in php

$travel_location = ‘1st main Road&Peenya Industrial Area’;

$bootloca = explode(‘&’,$travel_location);
$origins = str_replace(‘ ‘, ‘+’, $_REQUEST[‘city’]);
$destinations = ”;
foreach($bootloca as $book):
$destinations = $destinations.str_replace(‘ ‘, ‘+’, $book).’|’;



//print ‘<pre>’;
//print_r($json);   // for check array value
//print ‘</pre>’;
$total_distance = 0;
foreach($json[“rows”][0][“elements”] as $dist):

$total_distance += ceil($dist[“distance”][“text”]);


print $total_distance;

Logout link for Joomla 1.5, 2.5

Joomla 1.5 Logout Link

$returnURL = base64_encode(JURI::root() . “”);
$user =& JFactory::getUser();
echo ‘Hi,’.$user->username;

<a href=”index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>”>
<input  type=”button” name=”Submit” value=”Logout”></a>

Joomla 2.5 Logout Link

<a href=”index.php?option=com_users&task=user.logout&<?php echo JUtility::getToken(); ?>=1″>
<input  type=”button” name=”Submit” value=”Logout”>


Edit profile link for joomla 2.5

<a href=”<?php echo JRoute::_(‘index.php?option=com_users&view=profile&layout=edit’)?>” title=”My Profile”>Edit Profile</a>