Question

I'm building a module in Prestashop that requires multiple Controllers.

I decided to add them in the Tab, with one visible (the front one), and the others that are related to the first one, in hidden.

When I go to that main admin controller via the menu, it works fine, listing the various elements (renderList) and adding/updating/deleting them also.

Now, when I click on a the view icon, I go to my other admin controller that manage that specific entry (sub list, with it's own form, but related to the parent id).

The problem now, is that I redirect by keeping the correct url, but then, on my sub page, if I click on create for example, I lost the parent_id. And after that, I can't create an entry because it's missing it's parent id.

How can I do to say to this sub controller to keep the id I gave it ?

Was it helpful?

Solution

So far, the only solution I come from is to do like this :

In my sub controller, I should always have id_other_model in the url, so I added this method :

public function initProcess() {
    parent::initProcess();
    self::$currentIndex .= '&id_other_model='.(int)Tools::getValue('id_other_model');
}

And so far it works well.

If there is a better alternative, I'd appreciate to know it :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top