Friday, 4 March 2016

Magneto 2 installation

1. Download Magento 2.02 from

2. Put your downloaded folder in www/html
suppose my folder name is m2

go to
cd /var/www/html/m2

3. Make webdata in you user list
chown -R  :www-data .

4. Set file permission:

  sudo find . -type d -exec chmod 770 {} \; && sudo find . -type f -exec chmod 660 {} \; && sudo chmod u+x bin/magento

5. Create virtual host
suppose we created http://local.m2/

6. Start installation

sudo php bin/magento setup:install --base-url=http://local.m2/ \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=User \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1

Installation will complete after a while and it will give you admin url

7. Give full permission to some public folder
sudo chmod -R var/
cd pub/
sudo chmod -R media/ static/

Thats all
go to your url


Monday, 18 January 2016

adding conditional css for firefox

var j = jQuery.noConflict();
if ( j.browser.mozilla == true ) {
      document.write('<link type="text/css" rel="stylesheet" href="">');
 } else {
document.write('<link type="text/css" rel="stylesheet" href="../css/font-awesome.min.css">');

Wednesday, 30 December 2015

Creating a jquery function to make all class with same height

 //Creating a jquery function to make all class with same height

function equaliseDivOnClass(class1){
                    var j = jQuery.noConflict();
     var divheights = 0;
j("."+class1).each(function( i ) {
  if(j(this).height() > divheights){
divheights = j(this).height();

Usage: equaliseDivOnClass("f-desc");

//Creating a jquery function to make 2 div with different id same height

function equaliseDiv(div1, div2){
               var j = jQuery.noConflict();
x = j(div1).height();
y = j(div2).height();
if (x > y) {
j(div2).height(x); }
else {


Usage: equaliseDiv("#s1", "#s2");

Thursday, 26 February 2015

Logging all the sql in Magento for debug

In Magento development you need some time to check the sql query running in the background

For this you can insert a code into the lib/Varian/Db/Adaptor/Pdo/Mysql.php

$code = 'SQL: ' . $sql . "\r\n";
if ($bind) {
       $code .= 'BIND: ' . print_r($bind, true) . "\r\n";
$this->_debugWriteToFile("[".date('Y-m-d H:i:s')."] ".$code);

in your query method of the page.
now your query method look like

    public function query($sql, $bind = array())
        try {
            $this->_prepareQuery($sql, $bind);
/* Inserted code Starts */
           $code = 'SQL: ' . $sql . "\r\n";
           if ($bind) {
                $code .= 'BIND: ' . print_r($bind, true) . "\r\n";
          $this->_debugWriteToFile("[".date('Y-m-d H:i:s')."] ".$code);
/* Inserted code Starts */

            $result = parent::query($sql, $bind);
        } catch (Exception $e) {
            $this->_debugStat(self::DEBUG_QUERY, $sql, $bind);
        $this->_debugStat(self::DEBUG_QUERY, $sql, $bind, $result);
        return $result;

You can find the log at /var/debug/pdo_mysql.log

Mage::log("MyArray:".print_r($arr,true), null, 'logfile.log');

Friday, 12 December 2014

getting top category on the product listing or product details page

create a method in your helper:

class Rajiv_Catalog_Helper_Data extends Mage_Core_Helper_Abstract {
public function getTopCat(){
$category = Mage::registry('current_category');
$it = 10; //Amount of iterations before script gives up

if ($category) {
while($category->getLevel() != 2 && $it > 0) {
$category = $category->getParentCategory();

if (!$category) {

if ($category) {
return $category->getName();


Call the method anywhere as

echo Mage::helper('rajiv_catalog')->getTopCat();

Tuesday, 2 December 2014


You have to install the open-terminal package :
sudo apt-get install nautilus-open-terminal
nautilus -q

in order to reset Nautilus

find . -type f -exec chmod 644 {} \;

Linux command:
-> To check server space
df -h 

-> To check folder space
du -sh foldername/

--> To check version and flavor of linux on server
cat /proc/version

--> Creating a tar.gz file
tar -czvf truconnect_qa_20170601.tar.gz truconnect_qa_20170601.sql

--> To view appended content in real time
tail -f filename

Monday, 24 November 2014

How to get Magento If official download link is breaking

From some time I found that official download link of magento CE at the magento site is breaking.
So you can use the alternative way for this to get it from github

Here is the magento mirror for Magento CE version

You can also get sample data for CE at following location of github

I greatly appreciate the concerned contributor/author to github  who have contributed this github for the public use.

This blog is only the benefit of public who facing issue with download link on the official site. However I recommend that you always try to take a copy for the official magento site(which will be more reliable).

NOTE: This article is also not a way to say any complaint to official site in any way.