Wednesday, 7 December 2011


1) Download PHP-Java bridge here.

2) Extract the Zip there you can find JavaBridge.war extract that too.

3) You can find JavaBridge.jar here [JavaBridge.war\WEB-INF\lib\]. Copy that file to your lib\php\modules [LINUX]. For windows xampp/php/ext.

4) Run this command 

java -jar /usr/lib/php/modules/JavaBridge.jar HTTP_LOCAL:8088 3 JavaBridge.log

5) Make sure the path in above command is matches your path where you have placed the JavaBridge.jar

6)Make sure port 8088 is not listening some other service like tomcat.

7)Extract JavaBridge.jar and copy the java folder which is present in JavaBridge.jar\META-INF\  to wherever you want.  [Don't change the existing one which is present in your ext or module folder] 

8) Then run the below. It will display the info and java bridge version and some other properties.

9) require_once("java/"); [Present in the below coding]. You need to change the path as per your requirement.
/* load extension and check it */
function check_extension() {
  if(!extension_loaded('java')) {
    $sapi_type = php_sapi_name();
    if ($sapi_type == "cgi" || $sapi_type == "cgi-fcgi" || $sapi_type == "cli") {
      if(!(PHP_SHLIB_SUFFIX=="so" && @dl(''))&&!(PHP_SHLIB_SUFFIX=="dll" && @dl('php_java.dll'))&&!(include_once("java/Java.php"))) {
          echo "java extension not installed.";
    } else {
  if(!function_exists("java_get_server_name")) {
    echo "Fatal: The loaded java extension is not the PHP/Java Bridge";


  print "\n\n";

  $v = new Java("java.lang.System");
  $p = @$v->getProperties();
  if($ex=java_last_exception_get()) {
    $trace = new Java("");
    $ex->printStackTrace(new java("", $trace));
    echo "Exception $ex occured:<br>\n" . $trace . "\n";
  foreach ($arr as $key => $value) {
    print $key . " -> " .  $value . "<br>\n";
  echo "<br>\n";
  $Util = new JavaClass("");
  echo "JavaBridge back-end version: ".java_values($Util->VERSION)."<br>\n";
  echo "<br>\n";

  // java.util.Date example
  $formatter = new Java('java.text.SimpleDateFormat',
                        "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz");

  print $formatter->format(new Java('java.util.Date'));
  echo "<br>\n";

 } else {

  print "\n\n";

  /* java_get_server_name() == null means that the back-end is not
   running */
  if(PHP_SHLIB_SUFFIX=="so") $ext_name="";
  else if(PHP_SHLIB_SUFFIX=="dll") $ext_name="php_java.dll";
  else $ext_name="unknown suffix: ".PHP_SHLIB_SUFFIX;

  echo "Error: The PHP/Java Bridge back-end is not running.\n";
  echo "\n";
  echo "Please start it and/or check if the directory\n";
  echo "\n\t".ini_get("extension_dir")."\n\n";
  echo "contains \"$ext_name\" and \"JavaBridge.jar\".\n";
  echo "\n";
  echo " Check if the following values are correct:\n\n";
  echo "\tjava.java_home = ".ini_get("java.java_home")."\n";
  echo "\ = ".ini_get("")."\n\n";
  echo "If you want to start the back-end automatically, disable:\n\n";
  echo "\tjava.socketname = ".ini_get("java.socketname")."\n";
  echo "\tjava.hosts = ".ini_get("java.hosts")."\n";
  echo "\tjava.servlet = ".ini_get("java.servlet")."\n";
  echo "\n";
  echo "If that still doesn't work, please check the \"java command\" above and\n";
  echo "report this problem to:\n\n";
  echo "\\n";

Reference taken From ::

Wednesday, 16 November 2011

Jquery history plugin in magento

Main aspect of this is , at the time of using ajax powered search some one has search some thing and they have refreshed the page then they need to make the search another one time but using this plugin you can achieve the same result after the user have refreshed their page. Although it will work in the startergy for browser back and front button

Add history plugin js in your layout.xml as below [You can download the jquery plugin here :]

<reference name="head">
      <action method="addJs"><script>javascript/jquery.history.js</script></action>

And then add the hash (#store | #product) to your href for example you have store and product search in your application the it will goes like below.

href="#store" onclick="jQuery.history.load('store');" [to search stores]

href="#product" onclick="jQuery.history.load('product');" [to search products]

You need to add the below script in your basic template if your using for 1column page then you need to add the below snippet inside the head tag.

<script type="text/javascript">
        var flag = false;
                    flag =true;
                    SwapBwnStoreProducts(url == "" ? "" : url);
                    SwapBwnStoreProducts(url == "" ? "product" : url);

use the below function for your ajax call you can write this function in a separate file and then you need to include the same in the layout xml of your module.

function SwapBwnStoreProducts(swap){  
     ajax call goes here

Sunday, 13 November 2011

Magento Block Over ride

Here i am going to over ride catalog layer view  [Mage_Catalog_Block_Layer_View]
Config.xml file need to same as that of below.
<?xml version="1.0"?>

Then you need to create a class file [Class Modulename_Catalog_Block_Layer_View]  with the function you need to over ride .
No need to change the function name because the system and the config will automatically override the previous one.

Using the above same way you can rewrite models also.