Wednesday, December 25, 2013

WAMP PID 4 Port 8 busy

Hello,

If you are on Windows 7 and WAMP is not working.You have closed SKYPE, changed its default ports etc, and any other related software which can possibly use port 80, and still WAMP doesn't start. Specifically Apache.

A little bit of Goggling can tell you that Port 80 is taken by Windows 7, Pid 4 in Task Manager, further you can find out that its a system process and it cannot be killed.

I found that there is service named http.sys which captures  port 80 on start-up and it needed to be stopped in order to release port 80.

It has to be disabled through REGEDIT, following are the steps for the same,

  1. Launch regedit, run-> type regedit
  2. Go to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
  3. Locate Start
  4. Change the value to 4 which means disabled.
  5. Restart your system.
  6. Now your WAMP should work.

Thanx

Anshumaan Bakshi



Monday, December 23, 2013

ERROR 2006 (HY000) at line 8245: MySQL server has gone away

Hello,

If you are trying to import an SQL file through command line on windows and you get this error message

ERROR 2006 (HY000) at line 8245: MySQL server has gone away

then you need to open your my.cnf or my.ini and update as

max_allowed_packet = 3000M

more than the size of the file you are trying to import, like I was trying to import a 2.2 GB file.

Thanx
Anshumaan Bakshi

Wednesday, November 20, 2013

WAMP phpMyAdmin error #2002 - No connection could be made because the target machine actively refused it.

Hello,

If you get an error #2002 - No connection could be made because the target machine actively refused it when you try to access phpmyAdmin on a WAMP.

Then it is due to your 3306 port is already occupied by some other application. For me it was Skype today, I just needed to close Skype and restart the WAMP server once again and the issue was fixed. Skype will anyways take another vacant port so restart it as well.

You can make changes to my.ini so that it listens to another port, but easier to close Skype.

Try it.

Thanx
Anshumaan Bakshi

Tuesday, October 22, 2013

Magento Correcting the default taxing module for calculating tax based on discounted price

Hello,

Lets assume your client has a requirement of calculating tax based only on the discounted price.

Like,
The price of the item with tax is 100
Discount on this item with tax is 25
The remaining amount with tax is 75

If I consider 14% as tax then the tax should be shown as 9.21 and this is already part of 75. So if I subtract 9.21 from 75 then I will get 65.78, if I calculate 14% of 65.78 then I will get 9.21 to be exact.

In Magento this seems to be difficult to achieve by default configurations as if you enter item price without tax and discount is entered or calculated with tax.

I have checked it is not possible without a custom module.

Unfortunately cannot paste the entire module here but here are few pointers for resolving such issue.

  1. Main change we need to make is in the Quote Taxing module which is responsible for all the configuration based tax calculations, like in my case I was using unit based taxing so we have switch case which needed to be edited. This is the module which will return the actual tax amount so by changing it we are making the core change for recalculating the tax.
  2. Because of the above change we have our grand total all messed up, which needed to be corrected in Quote/address/grand file.
  3. Above 2 file will ensure that the new way of calculating tax has been enforced on frontend, but back end still needed to be changed
  4. The way Magento calculates row totals is, it adds the base price with the tax amount and hence we get row totals, but if the tax is based on the discounted price then adding it to the product price will give an incorrect result, fortunately this happens only at adminhtml template level, so as it being cosmetic change only we need to change the order, invoice view and create templates.
  5. Also we need to change the invoice subtotal calculation file as the final calculations is effected as I explained earlier.
If all the above changes are in place properly then the desired change will be achieved, I have tested and developed this module.

Thanx
Anshumaan Bakshi

Import MySql DB through command prompt on WAMP

Hello,

If we have a very large file to import on WAMP and PHPMyAdmin is dying due to various reasons then you can import the big file using CLI or through Dos

Follow the following steps.
  1. Run cmd command
  2. Assuming you have installed wamp on C: drive.
  3. C:>cd wamp
  4. C:\wamp>cd bin
  5. C:\wamp\bin>cd mysql
  6. C:\wamp\bin\mysql>cd mysql15.5.8
  7. C:\wamp\bin\mysql\mysql15.5.8>cd bin
  8. C:\wamp\bin\mysql\mysql15.5.8\bin>mysql.exe -u root -p dbname < sqlDump.sql
  9. Now we need to have the sqlDump.sql file inside C:\wamp\bin\mysql\mysql15.5.8\bin\ for direct execution of this command.
  10. If everything is fine, then this command will ask for the mysql password for username root and it should start importing the file on the mysql database.

Now what we are doing here is we are moving to WAMP's bin directory to locate the mysql.exe file. This command file is similar to the one we have on Linux and it behave s the same way, so we provide the information like username db and import sql file and it can easily be imported in our db.

Please note: We can also use direct path from any location as soon as we come to cmd like C:\wamp\bin\mysql\mysql15.5.8\bin\mysql.exe -u root dbname < sqlDump.sql
but need to be sure of the path which is hard to locate.

Thanx
Anshumaan Bakshi

Friday, July 26, 2013

Kohana Framework: My Experience

Hello everyone,

Recently I went for an interview, the job was for a Magento development position.

After the initial screening the interviewer said they will test me on something which not many people use, so that they know I work with a new framework, this was the first time I heard of Kohana framework.

Anyways, the task was to develop this small module in Kohana, which is done.I also thought I should record what I have learnt in last 2 days.

Kohana is an HMVC(Hierarchical model–view–controller) PHP5 framework.

Official website: http://kohanaframework.org/ which has a download link as well. Latest stable version is 3.3.0 'badius' right now.


Installation:

Download the package and extract it where you have your webserver's webroot. There is no requirement of database setup, if your application doesn't require any database then you don't need to set it up ever.

After extraction if you open up the framework folder through your browser like http://localhost/kohana then the framework will provide you with information on setup and if its requirements are fulfilled or not.
If everything is fine then it will ask you to rename / remove the index.php file. If you are at this stage then we are pretty much done with the installation.

Few posts on the net says to play with \kohana\application\config\config.php file for some configuration, believe me the framework has evolved since then and nothing is required as such. Infact in the latest version of Kohana you won't even find a config.php in \kohana\application\config.


Tuesday, July 16, 2013

Magento Instillation Issue - Database server does not support InnoDB storage engine

Hello Everyone,

If you are using WAMP and your get following error message while installing any version of Magento.


' Database server does not support InnoDB storage engine '.


Then do not try to fix this issue by messing with my.ini or my.cnf file, in other word do not change your MySQL configuration.

The issue is with MySQL ver 5.6 and InnoDB storage Engine, no matter what you do it doesn't work. I have spent too much time on it and I know.


The quickest way is to uninstall your current WAMP server and install a WAMP server which is has MySQL server version lower than 5.6 like 5.5.24 and your issue will be resolved for sure.

One thing though once you uninstall you WAMP server the PHP scripts will remain but MySQL DB files may get deleted, so be careful.

Thanx
Anshumaan Bakshi


Monday, July 8, 2013

How to use PHP through CLI (command line interface) on WAMP - Windows


Hello Everyone,

If you have a requirement that you want to execute a PHP script through CLI on windows, then here are few pointers to help you with that.


First we need WAMP on our system.

And then, we need to locate php.exe, which should be in WAMP's directory. Normally at

C:\wamp\bin\php\php5.4.16\php.exe



Now we can run a PHP script from anywhere on a windows system, we just need to run it with the path to the php.exe file.

Like, I open up my command prompt by going to Windows>Run>cmd

I created a simple PHP script like

test.php

<?php
echo 'hello';
?>

Now if I am in the same folder as test.php is then I can run command like

C:\wamp\bin\php\php5.4.16\php.exe   test.php

I will get ' hello ' as the out out.


If I have my PHP script in some other directory then simply add the path to the file. Like

C:\wamp\bin\php\php5.4.16\php.exe   C:\wamp\www\test.php

It will definitely give an output.

Thanx
Anshumaan Bakshi

Thursday, July 4, 2013

Best way to import large .sql files to PHPmyAdmin via WAMP

Hello everyone,

Say you get an error message in PHPmyAdmin as

' Script timeout passed, if you want to finish import, please resubmit same file and import will resume. '

Or you have reached maximum file upload limit.

On WAMP you can use following steps to ensure your .sql files gets through.

  1. Click on the WAMP icon right next to time on your desktop.
  2. Goto PHP > php.ini
  3. php.ini file will open.
  4. Now search for following variables in the file and change the values as given below
    1. post_max_size = 750M
    2. upload_max_filesize = 750M
    3. max_execution_time = 300
    4. max_input_time = 540
    5. memory_limit = 1000M
  5. Save and close the php.ini file.
  6. Restart the WAMP server via the WAMP icon on the system tray, the option is called Restart all Services.
  7. This should import a large .sql file.
What we are doing here is we are increasing the php variables to a larger level, like file size or execution time  etc, so now the PHPmyAdmin is capable enough to import a larger file easily.

In latest version of WAMP it is possible that some of the variables will not be found, but whatever you can find, you should replace it with higher values.

Hope it fixes your issue.

Thanx
Anshumaan Bakshi