Jump to content

Adding new catalog after module installation


Recommended Posts

this is how i add tab to AdminOrders tab to my free module: delete orders free
it adds new menu item to "orders" tab:
        $this->tabClassName = 'deleteorderstab';
        $this->tabParentName = 'AdminOrders';
        $tab->class_name = $this->tabClassName;
        $tab->id_parent = Tab::getIdFromClassName($this->tabParentName);
        $tab->module = $this->name;
        $languages = Language::getLanguages();
        foreach ($languages as $language)
          $tab->name[$language['id_lang']] = $this->displayName;
        $tab->add();

instead of adminOrders use adminCatalog :-)

Link to comment
Share on other sites

 

this is how i add tab to AdminOrders tab to my free module: delete orders free
it adds new menu item to "orders" tab:
        $this->tabClassName = 'deleteorderstab';
        $this->tabParentName = 'AdminOrders';
        $tab->class_name = $this->tabClassName;
        $tab->id_parent = Tab::getIdFromClassName($this->tabParentName);
        $tab->module = $this->name;
        $languages = Language::getLanguages();
        foreach ($languages as $language)
          $tab->name[$language['id_lang']] = $this->displayName;
        $tab->add();

instead of adminOrders use adminCatalog :-)

 

 

Thanks you for the reply.

 

But one quick question, where should I put that code?

Link to comment
Share on other sites

Thanks vekia,

 

    public function install()
    {
        
        $this->tabClassName = 'deleteorderstab';
        $this->tabParentName = 'AdminCatalog';
        $tab->class_name = $this->tabClassName;
        $tab->id_parent = Tab::getIdFromClassName($this->tabParentName);
        $tab->module = $this->name;
        $languages = Language::getLanguages();
        foreach ($languages as $language)
          $tab->name[$language['id_lang']] = $this->displayName;
        $tab->add();

       
        return (parent::install()
            && Configuration::updateValue('posbang_productsorting_company', Configuration::get('PS_SHOP_NAME'))
            && Configuration::updateValue('posbang_productsorting_address', '') && Configuration::updateValue('posbang_productsorting_phone', '')
            && Configuration::updateValue('posbang_productsorting_email', Configuration::get('PS_SHOP_EMAIL'))
            && $this->registerHook('header') && $this->registerHook('footer'));
    }

 

That is how I do it, but I get this error below:

 

[PrestaShop] Fatal error in module productsorting:
Call to undefined method stdClass::add()

Edited by chesspiece423 (see edit history)
Link to comment
Share on other sites

you have to create $tab variable first, it must abe a Tab object

$tab = new Tab();

It worked thanks. But I messed up at first. How do I remove the wrong tabs? It won't disappear even if I uninstall the module.

 

Second question is, how can I put a link to my new added tab? When clicked, I want it to redirect to the module I made.

 

Thank you for your assistance.

Link to comment
Share on other sites

you can remove wrong tabs under administration  > menu section in your back office

Thanks.. how to remove these links(attachment)..

 

How can I put a link to my new added menu? When clicked, I want it to redirect to the module I made.

 

Thank you for your patience

post-787487-0-92438600-1407288969_thumb.png

Link to comment
Share on other sites

thse links works with module controllers

your module has got own admin controller?


 $this->tabClassName = 'deleteorderstab';
        $this->tabParentName = 'AdminCatalog';
        $tab->class_name = $this->tabClassName;

in this case it's 'deleteorderstab' admin controller, you have to create own controller

Link to comment
Share on other sites

Thank you for your assistance. I've downloaded your free module and studied it.

But I'm really confused, I don't know how should I code it.

 

All I wanted is:

1. Install my module

2. A child 'link' will appear to the parent tab 'AdminCatalog' after installation

3. The 'link' will redirect me to the module I made.

 

Your module is what I'm really talking about. It is what I really needed.

 

Can you instruct me step by step how? Thanks :> much appreciated!

Link to comment
Share on other sites

×
×
  • Create New...