How we can create Joomla menus using excel sheet of 2k rows?. I created the script but it gets time out after certain number of insertion i.e. 50 or 100 sometime.

    foreach($finalData as $key=>$val)
{
    echo $key."<br/>";
    $params     =   [
        "service_description"   =>  $val[7],
        "contact_number"        =>  $val[8],
        "contact_email"         =>  $val[9],
        "keywords"              =>  $val[10],
        "price"                 =>  $val[11],
        "banner"                =>  $defaultBanner,
        "menu-anchor_title"     =>  "",
        "menu-anchor_css"       =>  "",
        "menu_image"            =>  "",
        "menu_image_css"        =>  "",
        "menu_text"             =>  1,
        "menu_show"             =>  1,
        "page_title"            =>  "",
        "show_page_heading"     =>  "",
        "page_heading"          =>  "",
        "pageclass_sfx"         =>  "",
        "menu-meta_description" =>  $val[7],
        "menu-meta_keywords"    =>  $val[10],
        "robots"                =>  "",
        "secure"                =>  0
    ];


    $custom_data    =   [
        "parent_id"             =>  $jinput->get("parent_id"),
        "level"                 =>  2,
        "menutype"              =>  "mainmenu",
        "title"                 =>  "Sameday and On Board Couriers in ".$val[2],
        "type"                  =>  "component",
        "link"                  =>  "index.php?option=com_couriercsv&view=courier",
        "published"             =>  1,
        "browserNav"            =>  0,
        "access"                =>  1,
        "template_style_id"     =>  0,
        "params"                =>  json_encode($params),
        "home"                  =>  0,
        "language"              =>  "*",
        "client_id"             =>  0,
        "component_id"          =>  $component->extension_id
    ];

    $menu   =   JTable::getInstance('Menu','MenusTable');

    // menu if present 
    $menu->load(0);

    $menu->setLocation($custom_data['parent_id'], 'last-child');

    $menu->bind($custom_data);
    $menu->store();

    if($menu->id)
    {
        $menu->rebuildPath($menu->id);
        // store the menu id
    }

}
  • 1
    Have you tried converting your excel spreadsheet to SQL? Maybe this will help: sqlizer.io/# – Lodder Nov 23 at 12:14
  • I am reading the file data using PHPExcel library and creating the object of each record and saving the data into the database using JTable class – Manoj Thakur Nov 23 at 12:19
  • Ahh I see. In which case can you share your code please? – Lodder Nov 23 at 12:20
  • Please see my code above – Manoj Thakur Nov 23 at 12:22

Apparently your script runs out of max_execution_time - You could temporary increase this to allow your script to complete, since this seems to be 1-shot action. Check also set_time_limit.

Another option would be to write a cli script and run it from the command line, where there is no max_execution_time restriction.

However if you are building an extension that will need to handle such imports on all kind of environments, then you should take a different approach - so that your script will have to make the imports in various steps that will take shorter time than the max_execution_time of each server and not in 1 go.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.