Change WordPress default FROM email address

WordPress is a very nice and easy blogging platform. But you can’t modify the FROM email adress by default. If you want toChange WordPress default FROM email address easily, follow the tutorial.

add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');

function new_mail_from($old) {
 return 'admin@yourdomain.com';
}
function new_mail_from_name($old) {
 return 'Your Blog Name';
}

Credits: Cool! Blogging

Posted in Wordpress | Tagged | Leave a comment

How did i speed up a Magento e-commerce website -1 ( Current status of our targeted example site )

Note: Speeding up or Optimizing an application requires a lot of R & D and of-course deep knowledge on how things work together. On this post, no steps of optimization is invented/discovered by me. All i have done here is compiling others advise and try to present on how to implement practically. So, this post owe to all who wrote articles, posts on application optimization, specially optimization with Mangento.

The website i am going to optimize is a popular e-commerce store selling cell phones online for the last 8 years and the site recently moves to magento. They have over 1500 product at this moment and in one or two months thier target is to have at least 20,000 products. On this post i shall term the website as http://www.targetsite.com.

Finding Current Server Environment:

OS & Hardware

1. Using SSH client, login into the server i ran the command to be confirmed if i am on fedora/redhat/centos

#head -n1 /etc/issue

And the output Fedora release 13 (Goddard) confirms me.

2. To checkcpuinfo

# cat /proc/cpuinfo
processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 107
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+
stepping        : 2
cpu MHz         : 2299.688
cache size      : 512 KB
.....

Webserver

3. To find the version

# httpd -v
Server version: Apache/2.2.17 (Unix)

MySQL

4. To check the version

mysql -V
mysql  Ver 14.14 Distrib 5.1.56, for redhat-linux-gnu (x86_64) using...

Magento Application

Products : ~1500
Extensions Installed: 103 including defaults [ more extensions less performance :) ]
Magento Cache : Disabled [ I disabled this at this point to perform optimization step by step ]

Checking Current Performance

This installation shows the following performance status using ab ( ApacheBench)

# ab -n 100 -c 5 http://www.targetsite.com/
Concurrency Level:      5
Time taken for tests:   229.616 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      12459400 bytes
HTML transferred:       12422700 bytes
Requests per second:    0.44 [#/sec] (mean)
Time per request:       11480.817 [ms] (mean)
Time per request:       2296.163 [ms] (mean, across all concurrent requests)
Transfer rate:          52.99 [Kbytes/sec] received

Percentage of the requests served within a certain time (ms)
  50%  11372  (quickest request)
 ............
 100%  13651 (longest request)

And Output in YSlow

output on yslow

And Analysis from Google Page Speed

Required loading time of Home Page on various connection rate using web-based tool

However, this is all about the current performance status of the targetsite.com. On my next followup posts i shall start implementing various optimization steps. Until then stay tuned!

Happy Optimizing :)

Posted in Magento, optimization | Leave a comment

How did i speed up a Magento e-commerce website -2 ( Optimizing MySQL for Magento )

First thing first. Some quick check using phpMyAdmin [ Most developer should have access to this ]

1. Check table

2. Repair table [ If required ]

3. Optimize table

To do so, you can run command from mysql> command line Or from phpMyAdmin. Please check on the bottom of the table list. There is a select box titled “With Selected”. You can perform the task from there. In my case, i found everything OK.

4. Configuring MySQl Query Cache

A. Checking if query cache is available on the server

mysql> SHOW VARIABLES LIKE 'have_query_cache';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| have_query_cache | YES   |
+------------------+-------+

So, we have query cache.

B. Checking if query cache is available on the server

mysql> SHOW VARIABLES LIKE 'query_cache_size';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| query_cache_size | 0     |
+------------------+-------+
1 row in set (0.00 sec)

So, query cache is not configured. We have to configure this.

C. Configuring Query Cache

# vi /etc/my.cnf
[mysqld]
...

query_cache_size=64M
query_cache_type=1
query_cache_min_res_unit=4KB
query_cache_limit=2MB

...

#service mysqld restart

So, mysql query cache should be inaction.
I have found this article very explanatory for whom who wants to understand things behind the scene. And you also can get help from here.

mysql> SHOW VARIABLES LIKE 'query_cache_size';
+------------------+----------+
| Variable_name    | Value    |
+------------------+----------+
| query_cache_size | 67108864 |
+------------------+----------+
1 row in set (0.00 sec)

To get more information for better maintenance run this command.

mysql>  SHOW STATUS LIKE 'Qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 1        |
| Qcache_free_memory      | 64226488 |
| Qcache_hits             | 2647     |
| Qcache_inserts          | 956      |
| Qcache_lowmem_prunes    | 0        |
| Qcache_not_cached       | 26       |
| Qcache_queries_in_cache | 863      |
| Qcache_total_blocks     | 1850     |
+-------------------------+----------+
8 rows in set (0.00 sec)

Now its time to see change in performance. Before that after running the site lets check the Qcache variable status

mysql>  SHOW STATUS LIKE 'Qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 1        |
| Qcache_free_memory      | 60745664 |
| Qcache_hits             | 10235    |
| Qcache_inserts          | 2179     |
| Qcache_lowmem_prunes    | 0        |
| Qcache_not_cached       | 69       |
| Qcache_queries_in_cache | 1959     |
| Qcache_total_blocks     | 4096     |
+-------------------------+----------+
8 rows in set (0.00 sec)

So, it indicates that some queries are cached now.

# ab -n 100 -c 5 http://www.targetsite.com/

Concurrency Level:      5
Time taken for tests:   176.169 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      12459400 bytes
HTML transferred:       12422700 bytes
Requests per second:    0.57 [#/sec] (mean)
Time per request:       8808.468 [ms] (mean)
Time per request:       1761.694 [ms] (mean, across all concurrent requests)
Transfer rate:          69.07 [Kbytes/sec] received

Percentage of the requests served within a certain time (ms)
  50%   8706
...
 100%  10341 (longest request)

So, there is 29% improvement in RPS ( Request Per Second ).

D. Innodb Configuration

Magento white-paper recommends innodb_buffer_pool_size be set at 50% to 80% of servers ram. If the web and database run on the same server it is better to set 50% of your ram. And if the mysql box is separate then  upto 80% can be set safely. But before working with innodb one should read this article. So we add the configuration value on my.cnf

innodb_buffer_pool_size         = 2048M  #Data Page Memory Buffer
# Table metadata requires 2-16M, Magento only has abt 330 tables
innodb_additional_mem_pool_size = 4M    #Data Dictionary < 16M

Alas! i do not find any significant improvement. Perhaps this is due to my lack of innodb knowledge. i just followed some example. However, i shall update this section later if i could find something new.

E. Split the load, running mysql on different server

Though some suggest to keep mysql on separate server I have found article where it is mentioned that this will have no significant impact on the overall performance. I give it a try as i have to speed up with 20000 product ultimately so i tried with every option.  After spiting the web server and mysql server i did not see any change rather i found a little decrease in RPS ( Request Per Second ).

Check: Looks like a nice tool for R & D.

Posted in Magento, optimization | Leave a comment

Do You know CSS? Basic Javascript? You are a jQuery Pro!

One of my colleague once asked me to teach jQuery in a very short time. He was very good in CSS. I gave him a 30 mins session that he found very useful later. I hope this will help some one else also.

Concept 1

What CSS does? Simply select html elements and apply styles to them. jQuery acts in the same way. You can select dom object in a similar fashion. Assume we have a html page like this

<html>
<head>
<title>jQuery Tips</title>
</head>
<body>
<div>Content for Div1 goes here</div>
<div id="div2">Content for Div2 with an id goes here</div>
<div>Content for Div3 with a class goes here</div>
<div><span>This is a div with a child of a parent div</span></div>
</body>
</html>

Before dive into code you need to include jQuery library. Add the line below into the head tag.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>

Using Google CDN, we just add the library into our code and the magical $() function is now available within our javascript.

Now as we know css, if we want the div with id should have red background color we should hook the div using css ID selector and apply the style as we want

<style>
 #div2{  /*ID selector */
   background-color:red;
}
</style>

As you know how to select an element with ID in css, you actually already know how to select an element as jQuery Object. See the code below:

<script>

$("#div2"); // you just hook the element

console.log($("#div2")); /* If you browse on firefox with firebug
installed, you can clearly see that this code writes "Object object"
cleanly indicating that this is an Object, more specifically thjis is a
jQuery object */

 //now play around with this
$("#div2").css('background-color','green');
 </script>

See! the same way, you can select using class selector   $(‘.div3′)  or tag selector $(‘div’)

The bottom line is: You can use almost any selector pattern used in css2 and css3 engine. Try it out!

Concept 2

Next awesome and beautiful thing of jQuery ( at least to me ) is the use of object literals  as its function arguments.

Here is a short note on Object literal:

<script>

var car = {};  // an object, named 'car' is defined which has no property or method

console.log(car) // clearly found that this is an object of type Object, 'Object object'

/* below we have defined another object named 'anotherCar' that has
property 'door', 'wheel' and a method 'drive' */

var anotherCar = {

   door:4,

   wheel:4,

   drive:function(){
       //function body
   }

}

</script>

The way of defining object in javascript is titled Object literal. How this is so beautiful in jQuery?

In jQuery, if a method takes argument, it takes several ways. To demonstrate this, think we want to have following look to our div with the id ‘div2′

  • Yellow background
  • Bold font
  • Green Text

To accomplish this using jQuery we can write:

<script>

$('#div2').css('background-color','yellow');
$('#div2').css('font-weight','bold');
$('#div2').css('color','green');

</script>

Or, as jQuery uses Object chaining design pattern same thing can be accomplished this way

<script>

$('#div2')
          .css('background-color','yellow')
          .css('font-weight','bold')
          .css('color','green');

</script>

Or a more handy way ( Here comes the role of Object literal ) , you first can define a object literal of the properties you need like

<script>

var cssAttr = {

         background:'yellow',
         fontWeight:'bold',
         color:'green'

}
</script>

And then simply pass this object to the function as its argument

<script>

var cssAttr = {

         background:'yellow',
         fontWeight:'bold',
         color:'green'

}

$('#div2').css(cssAttr);

</script>

Or, the less readable but more interesting ( for jQuery only ) way ( reduce line number in your code)

<script>

$('#div2').css({background:'yellow',fontWeight:'bold',color:'green'});

</script>

Refreshing !  Isn’t it?

Also never never forget to bookmark http://www.visualjquery.com/

Posted in jQuery | Leave a comment

How to integrate CKEditor & CKFinder in your CAKEPHP application

Here is a quick and dirty article . If you need integrating ckeditor and ckfinder with cakphp, jump onto this. I know you are brave!

Step 1:

Add the below codes in beforeFilter Function of app_controllers.php

$ckeditorClass = 'CKEDITOR';
$this->set('ckeditorClass', $ckeditorClass);

Step 2:

Download and extract CKEditor & CKFinder under webrrot/js directory. So the directory structure looks like something below:
app/webroot/js/ckeditor
app/webroot/js/ckfinder

Step 3:

Link the editors library to the cakephp applicaion. Like we can add on default.ctp

echo $this->Html->script('ckeditor/ckeditor.js');
echo $this->Html->script('ckfinder/ckfinder.js');

Step 4:

Now we need to add ckeditor replacing our basic html textarea control

<?php	echo $this->Form->textarea('custom_html', array('class'=>$ckeditorClass));?>
<script type="text/javascript">
	var CustomHTML = CKEDITOR.replace( 'ID OF YOUR TEXTAREA' );
</script>

Now, if you hit the browser , you can see the the WYSWYG CKEDITOR is loaded. But if you click on the image icon you can see that you can enter the path of the image BUT THERE IS NO ‘Browse’ Button to upload image from your Desktop. Here comes the role of CKFINDER. So we need to integrate the CKFINDER now. Before hand please keep in mind if you do not have a license for CKFINDER, it  will run with full functionality but as Demo. Which will not prevent you to do your objective.

Step 5:

To integrate CKFINDER we need to edit js/ckfinder/config.php. We need to adjust the value of two variables

$baseUrl = 'files/ckuploads/';//as we want to have all of our files under webrrot/files/ckuploads folder
$baseDir = $_SERVER['DOCUMENT_ROOT'].'/app/webroot/files/ckuploads/';

Step 6. Now need to integrate CKFINDER to CKEDITOR.  I need NOT to write this article as the whole article is based on this awesome article. But i cannot make this section working in my case from that. I took help from here. And this is the background of this new article.

CKEDITOR.replace( 'ID OF YOUR TEXTAREA CONTROL',
	{filebrowserBrowseUrl : '/js/ckfinder/ckfinder.html',filebrowserWindowWidth : '1000',filebrowserWindowHeight : '700'}
	);

Hit the browser, you can see the Browse button and if you click on the button a new window will be opened with the list of files. Right? No. it will raise an security issue as usually you are running this WYSWYG on admin control panel/dashboard or any restrictive area. It is not secure to use any WYSWYG editor  to take user input. However, we need to do authentication check.

Step 7:

Open up app/webroot/js/ckfinder/config.php.Define the method

function CheckAuthentication()

{

 if( isset($_SESSION['Auth']['User']) )

 {

  return true;

 }

 return false;

}

CKFINDER needs to be informed that cakephp uses a different session ID other than default. Add the code below on the very top of ckfinder/config.php file

session_name("CAKEPHP");
session_start();

You should be done by this time. NO? Whats the problem? Files are not uploading? Ohh… check the permission of the files/ckuploads folder. It should be 757

Happy WYSWYGing!

 

 

 

 

Posted in CakePHP | Leave a comment

I am surprised when i see mailto in detail

I use ‘mailto’ in HTML rarely. However, when i first find what can be done with this, i was just surprised. I really need to go through HTML in more depth. Click on the links below:

Simple Email me

Surprising Email me ( at least for me )

Posted in HTML | Leave a comment

Some handy commands for Redhat/Fedora/CentOS linux

This post is just a summary of some commands & tools that i need often to use.

Memory:
#free -m
#top
#sar 1 5

Get Server Information
#cat /proc/version
#cat /etc/fedora-release
#head -n1 /etc/issue
#cat /proc/cpuinfo
#cat /proc/meminfo
#uname -a | -s | -i  | -p | -m

Setting Timezone
Video Tutorial

Starting Service at Boot Time
#chkconfig –levels 235  [service name:e.g httpd] on

SSH HOST KEY ISSUE
.ssh/known-hosts
#ssh -o stricthostkeychecking=ask [IP]

Taking MySQL BackUp
#mysqldump -u [user] -p [dbname] | gzip -9 > backup.sql.gz
Restore MySQl Database
#gunzip < backup.sql.gz | mysql -u [user] -p [dbname]

File Transfer
#scp target destination
e.g. scp /path/to/file user@xxx.xxx.xxx.xxx:./


 

Posted in Linux | Leave a comment

How to transfer and test a site under a new hosting account emulating the real time scenario

For example, you have a live site built on wordpress. You want to move the site under new hosting but you want to test before domain re-pointing. As it is on shared server you cannot run the site using the IP directly. Or, you actually do not want to touch the database to set ‘siteurl’ option type thing for wordpress or path url for Magento after repointing.

In brief, you need to test like real time site whereas domain is still pointed and live on old hosting account.

I have the solution from a hosting company. May be helpful for someone.

Actually what do we need? We need to bypass DNService so that when we type our url to the browser and hit enter, browser should go the the new server not the old one.

We can do this using host file of our pc.

Lets say, our domain name is: ourexamplesite.com & the ip of the new server is 122.22.11.34. Just follow the steps and you are done

1. Open C:\WINDOWS\system32\drivers\etc\hosts

2. Enter the following entries:

122.22.11.34  ourexamplesite.com
122.22.11.34  www.ourexamplesite.com

Now from the pc you have made the necessary changes, your browser will hit the new server for the domain.

Nice! Right?

 

 

 

 

Posted in Hosting | Leave a comment

Magento 1.5 quick search returns all the products or unexpected result – a discussion and collected solutions

As you are on this post, most probably you have faced the magento quick search issue- it returns all the products without caring about the search words. And it gave me a hard time too. However here’s how i fixed the issue in my case.

Before digging more we need to understand the behind the scene rolepalyers:

Understanding 1:

Magento creates a single text line (e.g 11142-09-20R|Enabled|Sapphire|None|SAPPHIRE HD4350 1G HM PCI-E HDMI / DVI-I / VGA W/ 512M DDR2 VRAM|HD 4350|| ) and populate the column ‘data_index‘ of catalogsearch_fulltext table for all of its products when you run the action System > Index Management > ReIndex Data for ‘Catalog Search Index’ row from admin control panel. This text line basically generated based on the chosen fields / attributes that should go under search  at the time of setting attributes.

So, when we perform quick search, magento basically search on this string.

Understanding 2:

Magento provides 3 types of search option. 1. FullText , 2. LIKE & 3. Combine ( Full Text & LIKE) And for each of these three it generates 3 types of query that will run on the data_index field. If you want to play around with this, focus on the function prepareResult which is located on app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php. You can choose the option you want from System > Configuration  > Catalog > Catalog Search. Under this section you have to set ‘Search Type’.

Now, the problem for me was as the title says. When i search with  keywords ‘View Sonic Monitor’ on quick search section ( please note that advance search is working just fine ) , it shows almost all active products (357). Either it be View Sonic Or Transcend. Either it be Monitor or it is a Motherboard. No matter what you put as your search word, it always returns those 357 products.

Whereas if i run the generated query directly on the database, i have found that results are coming filtered. Not all the products are listed. Generated Queries were:

1. FULL TEXT :

SELECT STRAIGHT_JOIN '1', `s`.`product_id`, MATCH (`s`.`data_index`)
AGAINST ('View Sonic Monitor' IN BOOLEAN MODE)
FROM `catalogsearch_fulltext` AS `s`
INNER JOIN `catalog_product_entity` AS `e` ON `e`.`entity_id`=`s`.`product_id`
WHERE (MATCH (`s`.`data_index`) AGAINST ('View Sonic Monitor' IN BOOLEAN MODE))
AND `s`.`store_id`='1'

2. LIKE :

SELECT STRAIGHT_JOIN '1', `s`.`product_id`, MATCH (`s`.`data_index`)
AGAINST ('View Sonic Monitor' IN BOOLEAN MODE) FROM `catalogsearch_fulltext` AS `s`
INNER JOIN `catalog_product_entity` AS `e` ON `e`.`entity_id`=`s`.`product_id`
WHERE ((`s`.`data_index` LIKE '%View%' OR `s`.`data_index`
LIKE '%Sonic%' OR `s`.`data_index` LIKE '%Monitor%')) AND `s`.`store_id`='1'

3. COMBINED ( Fulltext & Like )

SELECT STRAIGHT_JOIN '1', `s`.`product_id`, MATCH (`s`.`data_index`)
AGAINST ('View Sonic Monitor' IN BOOLEAN MODE)
FROM `catalogsearch_fulltext` AS `s`
INNER JOIN `catalog_product_entity` AS `e` ON `e`.`entity_id`=`s`.`product_id`
WHERE (MATCH (`s`.`data_index`) AGAINST ('View Sonic Monitor' IN BOOLEAN MODE)
OR (`s`.`data_index` LIKE '%View%' OR `s`.`data_index`
LIKE '%Sonic%' OR `s`.`data_index` LIKE '%Monitor%')) AND `s`.`store_id`='1'

After doing some googling i have found this article helpful for me. I just do

Edit app/code/core/Mage/CatalogSearch/Block/Result.php
Uncomment lines 149 and 150

$this->getListBlock()
         ->setCollection($this->_getProductCollection());

And then change the line 172 from

$this->_productCollection = $this->getListBlock()->getLoadedProductCollection();

To

$this->_productCollection = Mage::getSingleton('catalogsearch/layer')->getProductCollection();

And it works!

BUT, at this point another issue has raised. magento search is written in a way where maximum possible results will come. Like, when i put ‘View Sonic Monitor’ then it returns all the products where any of the words ( View, Sonic, Monitor ) is present. Which is in some point of view, not expected. To me, quick search is one of the more important section as it is the place where my visitors are looking for a specific things not a generic list.

When i put ‘View Sonic Monitor’, i basically want the list of all monitors from view sonic. i do not want monitors of other brand. So, i have changed the code a little bit.

I edited the app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php file on line number 353 and 345 replacing the ‘OR’ with ‘AND’

Now, i can see ONLY the View Sonic Monitors on my search result instead of having all the products or generic search result.

Still does not work for you? Clean up your cache!

Posted in Magento | Leave a comment

Who We Are?

Our company is the one with young and experienced talents, who can always stand beside you to feel the advantages of latest technology. We view software development and outsourcing in terms of all out dedication to our clients. We value time, money and energy to fit the advance technology into your business. From the scratch and throughout your business we keep our vigilant eyes on solutions which we provide you. Our services are unique for your business and our commitment is sharp.

Our major services include addressing specific requirements of consultation, outsourcing software, website development and also hiring offshore employees for our clients.

We’re not only specialized in technology, but also in management and communication that make the difference in providing successful global services. Our Project Management and R & D services are anchor towards the vision.

VISION & VALUES

Reach the pinnacle in offshore software development by providing our clients with service excellence which harnesses competitive advantages in all aspects.

This vision has driven us to the following values:

  • Develop high quality and industry specific solutions
  • Exceed client expectations and retain 100% customers
  • Be cost effective and attain success globally with competitive advantages
  • Customer oriented approach
  • Devoted team work
  • Commitment to clients
  • Continuous Improvement
  • Professional Project Management

OUR WORK PHILOSOPHY

Sincere development to make IT MOST effective for your business and add MAXIMUM value to your return.

Our company strives to:

  • gain customer minds through continuous improvement
  • use the best technology but makes it simple for end user
  • attain business success by fulfilling client requirements

Live Outsource’s Work-Philosophy is as follows:

  • We enter into your minds to look into your requirements
  • - Often a company feels SOFTWARE as a solution to complicated & daunting tasks. Exactly where is the escape door pops up in Management’s mind now and then. This induces the company management to outsource IT solutions. Live Outsource comes for rescue at such a point.
  • We see your needs
  • Some companies understand the problem quite well – they know what they need; some just feel they have problem – they don’t know their problem specifically; some companies are totally unaware of their problems. Live Outsource encounters your situation with logical reasoning.
  • Take all necessary input from you: your thoughts, ideas and requirements
  • Viewing ‘You’ – the company, in terms of IT analysis, we set out your picture very clearly.
  • We simply transfer your ‘headache’ to our ‘brainstorm’
  • We transmit problem into solutions. This we do right after studying and vividly understanding your status. Our Development Team evaluates your company’s picture in terms of objective, technology, and management. We frame out the best among alternatives.
  • We then transform your ‘dream’ to a ‘world class solution’ for you
  • This is the development phase through which we adhere to communication, designing and testing your project.
  • We use best of team and technology to strive for a remarkable service for you
  • We consider the whole task from your viewpoint with patience and improving quality.

What we do not:

  • We do not pop up unrealistic promises
  • We do not hide our work methodology
  • We do not burden our clients with unnecessary queries
  • We do not know how to mess up work
Posted in Miscellaneous | Leave a comment