Skip to main content

Posts

Calculate the days difference between two dates using Jquery

$(document).ready(function () { $("#date1").datepicker({ minDate: new Date(2012, 7 - 1, 8), maxDate: new Date(2012, 7 - 1, 28) }); //$("#date2").datepicker({ minDate: new Date(2012, 7 - 1, 9), maxDate: //new Date(2012, 7 - 1, 28) });    $('#date1, #date2').datepicker({onSelect: function(dateStr) {       var d1 = $('#date1').datepicker('getDate');       var d2 = $('#date2').datepicker('getDate');       var diff = 0;       if (d1 && d2) {             diff = Math.floor((d2.getTime() - d1.getTime()) / 86400000); // ms per day       }       $('#calculated').val(diff); } }); }); Check Js Fiddle :  http://jsfiddle.net/MebwN/48/

Cache_dir must be a dir in Magento

This problem usually occurs when we move our site from one server to other, There are two solutions for this problem, Solution 1: Go to this location lib/Zend/Cache/Backend/ and open file.php  file you’ll see the code something like this protected $_options = array ( 'cache_dir' => null , 'file_locking' => true , 'read_control' => true , 'read_control_type' => 'crc32' , 'hashed_directory_level' => 0 , 'hashed_directory_umask' => 0700 , 'file_name_prefix' => 'zend_cache' , 'cache_file_umask' => 0600 , 'metadatas_array_max_size' => 100 ); change this code as below protected $_options = array ( 'cache_dir' => '/tmp' , 'file_locking' => true , 'read_control' => true , 'read_control

Display Categories in Magento

Here, I will show you how you can get list of all categories of your Magento Shop. You might want to display all categories in homepage or any CMS page. There are different ways to get the category listing. Here are some:- Get all categories The following code will fetch all categories (both active and inactive) that are present in your Magento Shop. $categories   = Mage::getModel( 'catalog/category' )                      ->getCollection()                      ->addAttributeToSelect( '*' ); Get all active categories The following code will fetch all active categories that are present in your Magento Shop. Thus filtering the inactive categories. $categories   = Mage::getModel( 'catalog/category' )                      ->getCollection()                      ->addAttributeToSelect( '*' )                      ->addIsActiveFilter(); Get active categories of any particular level The following code w

MySQL query get first and last day of month

# For current month SELECT DATE_FORMAT(CURDATE(), '%Y-%m-01') AS `First Day Of Current Month`; SELECT LAST_DAY(CURDATE()) AS `Last Day Of Current Month`; # For previous month SELECT DATE_FORMAT(CURDATE() - INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Previous Month`; SELECT LAST_DAY(CURDATE() - INTERVAL 1 MONTH) AS `Last Day Of Previous Month`; # For next month SELECT DATE_FORMAT(CURDATE() + INTERVAL 1 MONTH, '%Y-%m-01') AS `First Day Of Next Month`; SELECT LAST_DAY(CURDATE() + INTERVAL 1 MONTH) AS `Last Day Of Next Month`;

Magento : onepage checkout scrolling issue.

Open opcheckout.js and find gotoSection function and replace this function as follow. gotoSection: function(section) { var sectionElement = $('opc-'+section); sectionElement.addClassName('allow'); this.accordion.openSection('opc-'+section); this.reloadProgressBlock(section); jQuery("html, body").delay(10).animate({scrollTop: jQuery("#opc-"+section).offset().top }, 1000); },