Jump to content

Make A Look-A-Like-Clone Of Adminproductscontroller


Recommended Posts

Hi I'm developing a module for PS16+,

 

Is it possible to extend the existing classes instead of overriding them? I would like to extend the \AdminProductsController, it should look exactly like the original but at the same time be completely at the mercy of my custom controller.

 

Here is what I have:

 

ExtendedAdminController is launched when the tab to my module is clicked.

class ExtendedAdminController extends \ModuleAdminController
{
    
    public function __construct()
    {
        parent::__construct();
        $this->initController();
        $products = new ExtendedProductList();
        // DO STUFF WITH THE PRODUCTS, ADD TABS, REMOVE TABS, COLUMNS ETC.
        $products->display(); //THIS IS WHERE THE PROBLEM IS
    }
}
class ExtendedProductList extends \AdminProductsController
{
    public function __construct()
    {
        parent::__construct();
    }
}

$products->display(); gives me errors 

 

Undefined index: iso

Notice: Undefined index: img_dir in... app_icon.png

 

Alternatively: How do I create my own list of all the available products?

 

Sincerely grateful for suggestions!

 

Link to comment
Share on other sites

Solved! (Way easier than I could imagine)

 

Just needed to change. 

 

extends \ModuleAdminController -> AdminProductsController and remove $this->display();

the display() function is called automatically when all the right parameters have been set.

 

 
/* EXECUTION ORDER OF CONTROLLERS */
 
//__contruct(): Sets all the controller's member variables.
//init(): Initializes the controller.
//setMedia() or setMobileMedia(): Adds all JavaScript and CSS specifics to the page so that they can be combined, compressed and cached (see PrestaShop's CCC tool, in the back office "Performance" page, under the "Advanced preferences" menu).
//postProcess(): Handles ajaxProcess.
//initHeader(): Called before initContent().
//initContent(): Initializes the content.
//initFooter(): Called after initContent().
//display() or displayAjax(): Displays the content.
 
/* FINAL CODE */
 
 
class ExtendedAdminController extends \AdminProductsController
{

    public function __construct()

    {

        parent::__construct();

    }

}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...