Jump to content

How to display table in custom controller in ps 1.7?


Recommended Posts

Hello,

I want to develop a simple module in which I've created few tables and configuration page. Now I want to display the data from these tables along with some default PS tables like customer etc. So how can I do that. 

I'm new to prestashop and tried many solutions and table is displaying but no proper layout. So please share one complete example.

Thanks!

Link to comment
Share on other sites

If I understood correctly, you need to just show some variables from db?

In your controller/module/some php file:

public static function getAddressCustom($id_customer){
$result = Db::getInstance()->getRow('
            SELECT *
            FROM `'._DB_PREFIX_.'address` sample
            WHERE sample.`id_customer` = '.(int)$id_customer
        );
}

Before to send the variables to the smarty, I recommend you to make all manipulations in php file, and after sent the proper data.Assign variable to the .tpl file, where 'customer_current_address' is your variable name in smarty

$this->context->smarty->assign('customer_current_address', $result);

P.S. check SQL queries here

P.S2: 

 You have power of "$this", for example :

//get customer cart id
$this->context->cart->id
//or changing delivery option to some custom id (dont run it like this)
$this->context->cart->setDeliveryOption(array($this->context->cart->id_address_delivery => $delivery_option));
$this->context->cart->save();

 

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

Hello,

Thank you for your comment but our file is located under modules/test/controllers/admin/some.php. So,

1. Is the path correct?

2. We are able to get the data but main issue is while trying to display this data using table, it is not displaying in proper format. No bootstrap, css is applied. So please share one example for this.

Thanks!

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...