How to : integrate wordpress menu into prestashop

The wordpress and prestashop integration is a big subject : prestashop is good for selling products and wordpress is good for dealing with content. One very efficient feature of wordpress is the menu builder that allows you to build unlimited hierachical menus. We submit here a technique that hooks into the wordpress update menu event to generate a static version of the modified menu, that can be then included in your prestashop theme via easy static include.

  1. create a cache directory in your wordpress theme folder
  2. add the following code to your functions.php file
      add_action("wp_update_nav_menu" , 'poleouestMakeMenu' );
      function poleouestMakeMenu($menuId)
      {
          $html=wp_nav_menu(array('menu'=>$menuId, "echo"=>false));
          $fileNAme= STYLESHEETPATH . "/cache/" . "menu" . $menuId .".html";
         
          file_put_contents($fileNAme,$html);
      }
  3. once you've tested that the menu . html file is generated, include it in your prestashop template via some hack in the prestashop core. Let us know how you do it !!
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *