title: Prestashop override Blocktopmenu function
body: <p>I'm trying to override the <code>generateCategoriesMenu</code> function from <code>blocktopmenu.php</code></p>
  
  <pre><code>class BlocktopmenuOverride extends Blocktopmenu
  {
    public function generateCategoriesMenu($categories, $is_children = 0)
      {
              die( var_dump ('hello I am an override') );
      }
  }
  </code></pre>
  
  <p>I've set up this in the folder override/modules cleared the cache file class_index.php</p>
  
  <p>when I load my index page I would expect a blank page with a string <code>'hello I am an override'</code></p>
  
  <p>I'm on 1.6.0.12</p>
  
  <p><strong>edit</strong></p>
  
  <p>I know I can do it the old way 'cloning' the module but there's a new undocumented hidden way in prestashop if you look in module.php this function clearly says that we can override a module.</p>
  
  <pre><code>    public static function getInstanceByName($module_name)
  {
      if (!Validate::isModuleName($module_name))
      {
          if (_PS_MODE_DEV_)
              die(Tools::displayError(Tools::safeOutput($module_name).' is not a valid module name.'));
          return false;
      }
      if (!isset(self::$_INSTANCE[$module_name]))
      {
          if (Tools::file_exists_no_cache(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'.php'))
          {
              include_once(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'.php');
              if (Tools::file_exists_no_cache(_PS_OVERRIDE_DIR_.'modules/'.$module_name.'/'.$module_name.'.php'))
              {
                  include_once(_PS_OVERRIDE_DIR_.'modules/'.$module_name.'/'.$module_name.'.php');
                  $override = $module_name.'Override';
                  if (class_exists($override, false))
                      return self::$_INSTANCE[$module_name] = new $override;
              }
              if (class_exists($module_name, false))
                  return self::$_INSTANCE[$module_name] = new $module_name;
          }
          return false;
      }
      return self::$_INSTANCE[$module_name];
  }
  </code></pre>
  
  <p>I already did successfully overrides on other modules with no problem,</p>
  
  <p>this override works if I comment the parent function but that makes pointless the override.</p>
  
  <p>why with blocktopmenu I can't override the desired function?</p>
  
  <p>I hope I made it clear now.</p>