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!

Share this post


Link to post
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)

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

1. Why it should be in front? We are creating back end controller.

2. We have checked the link but we are not looking for this. We want to display like customer list in prestashop. The main problem is in format.

Edited by OpenCart City
Added point 2 (see edit history)

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More