Prestashop 1.7.7 - HelperForm in a Multistore Context - module

I'm testing a first simple version for a Multistore-compatible module. It has just two settings, which have to be saved differently depending on the current shop Context (a single shop mainly).
Now, I know that from 1.7.8 there are additional checkbox for each setting in the BO Form, but I have to manage to get it work also for 1.7.7.
Now, both Configuration::updateValue() and Configuration::get() should be multistore-ready, meaning that they update or retrieve the value only for the current context, so it should be fine.
The weird thing is that, after installing the test module, if I go to the configuration page, it automatically redirects to an All-Shop context and, if I try to manually switch (from the dropdown in the top right), it shows a blank page. Same thing happens if I try to deactivate the bottom checkbox "Activate this module in the context of: all shops".
Here is my code:
class TestModule extends Module
{
public function __construct()
{
$this->name = 'testmodule';
$this->tab = 'front_office_features';
$this->version = '1.0.0';
$this->author = 'Test';
$this->need_instance = 1;
$this->ps_versions_compliancy = [
'min' => '1.7.0.0',
'max' => '1.7.8.0',
];
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l("Test Module");
$this->description = $this->l('Collection of custom test extensions');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
if (!Configuration::get('TESTM_v')) {
$this->warning = $this->l('No version provided');
}
}
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return (
parent::install()
&& $this->registerHook('header')
&& $this->registerHook('backOfficeHeader')
&& Configuration::updateValue('TESTM_v', $this->version)
);
}
public function uninstall()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return (
parent::uninstall()
&& $this->unregisterHook('header')
&& $this->unregisterHook('backOfficeHeader')
&& Configuration::deleteByName('TESTM_v')
);
}
public function getContent()
{
// this part is executed only when the form is submitted
if (Tools::isSubmit('submit' . $this->name)) {
// retrieve the value set by the user
$configValue1 = (string) Tools::getValue('TESTM_CONFIG_1');
$configValue2 = (string) Tools::getValue('TESTM_CONFIG_2');
// check that the value 1 is valid
if (empty($configValue1)) {
// invalid value, show an error
$output = $this->displayError($this->l('Invalid Configuration value'));
} else {
// value is ok, update it and display a confirmation message
Configuration::updateValue('TESTM_CONFIG_1', $configValue1);
$output = $this->displayConfirmation($this->l('Settings updated'));
}
// check that the value 2 is valid
Configuration::updateValue('TESTM_CONFIG_2', $configValue2);
$output = $this->displayConfirmation($this->l('Settings updated'));
}
// display any message, then the form
return $output . $this->displayForm();
}
public function displayForm()
{
// Init Fields form array
$form = [
'form' => [
'legend' => [
'title' => $this->l('Settings'),
],
'input' => [
[
'type' => 'text',
'label' => $this->l('Custom CSS file-name.'),
'name' => 'TESTM_CONFIG_1',
'size' => 20,
'required' => true,
],
[
'type' => 'switch',
'label' => $this->l('Enable custom CSS loading.'),
'name' => 'TESTM_CONFIG_2',
'is_bool' => true,
'desc' => $this->l('required'),
'values' => array(
array(
'id' => 'sw1_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'sw1_off',
'value' => 0,
'label' => $this->l('Disabled')
)
)
],
],
'submit' => [
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
],
],
];
$helper = new HelperForm();
// Module, token and currentIndex
$helper->table = $this->table;
$helper->name_controller = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&' . http_build_query(['configure' => $this->name]);
$helper->submit_action = 'submit' . $this->name;
// Default language
$helper->default_form_language = (int) Configuration::get('PS_LANG_DEFAULT');
// Load current value into the form or take default
$helper->fields_value['TESTM_CONFIG_1'] = Tools::getValue('TESTM_CONFIG_1', Configuration::get('TESTM_CONFIG_1'));
$helper->fields_value['TESTM_CONFIG_2'] = Tools::getValue('TESTM_CONFIG_2', Configuration::get('TESTM_CONFIG_2'));
return $helper->generateForm([$form]);
}
/**
* Custom CSS & JavaScript Hook for FO
*/
public function hookHeader()
{
//$this->context->controller->addJS($this->_path.'/views/js/front.js');
if (Configuration::get('TESTM_CONFIG_2') == 1) {
$this->context->controller->addCSS($this->_path.'/views/css/'.((string)Configuration::get('TESTM_CONFIG_1')));
} else {
$this->context->controller->removeCSS($this->_path.'/views/css/'.((string)Configuration::get('TESTM_CONFIG_1')));
}
}
}
As you can see it's a pretty simple setting: just load a custom CSS file and choose if loading it or not. I've red official PS Docs per Multistore handling and searched online, but cannot find an answer to this specific problem.
I've also tried to add:
if (Shop::isFeatureActive()) {
$currentIdShop = Shop::getContextShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $currentIdShop);
}
To the 'displayForm()' function, but without results.
Thank you in advance.

It seemsit was a caching error.
After trying many variations, I can confirm that the first solution I've tried was the correct one, meaning that:
if (Shop::isFeatureActive()) {
$currentIdShop = Shop::getContextShopID();
Shop::setContext(Shop::CONTEXT_SHOP, $currentIdShop);
}
needs to be added ad the beginning of the "displayForm()" function for it to work when selecting a single shop. Values are now correctly saved in the database. With a little bit extra logic it can be arranged to behave differently (if needed) when saving for "All shops" context.

Related

Prestashop : Can't make my module work : Get order details when order status is changed to “shipped”

I am developing a module, it gets order details when order status is changed to "shipped" by admin, to post them to a third-party application with API.
I am using Prestashop V 1.7.7.0.
The hook i'm using is hookActionOrderStatusPostUpdate
The module is installed successfully in the Backoffice and there's no syntax errors, But it doesn't do anything.
Can't figure out what's wrong in my code.
Need help please. Thanks
<?php
/**
* 2007-2021 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* #author PrestaShop SA <contact#prestashop.com>
* #copyright 2007-2021 PrestaShop SA
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class Cargo extends Module
{
protected $config_form = false;
public function __construct()
{
$this->name = 'cargo';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'tekwave';
$this->need_instance = 1;
/**
* Set $this->bootstrap to true if your module is compliant with bootstrap (PrestaShop 1.6)
*/
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('cargo');
$this->description = $this->l('Ce module permet la synchronisation entre Prestashop et Cargo');
$this->confirmUninstall = $this->l('');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}
/**
* Don't forget to create update methods if needed:
* http://doc.prestashop.com/display/PS16/Enabling+the+Auto-Update
*/
public function install()
{
Configuration::updateValue('CARGO_LIVE_MODE', false);
return parent::install() &&
$this->registerHook('header') &&
$this->registerHook('backOfficeHeader') &&
$this->registerHook('actionOrderStatusPostUpdate');
}
public function uninstall()
{
Configuration::deleteByName('CARGO_LIVE_MODE');
return parent::uninstall();
}
/**
* Load the configuration form
*/
public function getContent()
{
/**
* If values have been submitted in the form, process.
*/
if (((bool)Tools::isSubmit('submitCargoModule')) == true) {
$this->postProcess();
}
$this->context->smarty->assign('module_dir', $this->_path);
$output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/configure.tpl');
return $output.$this->renderForm();
}
/**
* Create the form that will be displayed in the configuration of your module.
*/
protected function renderForm()
{
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$helper->module = $this;
$helper->default_form_language = $this->context->language->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitCargoModule';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false)
.'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => $this->getConfigFormValues(), /* Add values for your inputs */
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
);
return $helper->generateForm(array($this->getConfigForm()));
}
/**
* Create the structure of your form.
*/
protected function getConfigForm()
{
return array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => 'switch',
'label' => $this->l('Live mode'),
'name' => 'CARGO_LIVE_MODE',
'is_bool' => true,
'desc' => $this->l('Use this module in live mode'),
'values' => array(
array(
'id' => 'active_on',
'value' => true,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => false,
'label' => $this->l('Disabled')
)
),
),
array(
'col' => 3,
'type' => 'text',
'prefix' => '<i class="icon icon-envelope"></i>',
'desc' => $this->l('Enter a valid email address'),
'name' => 'CARGO_ACCOUNT_EMAIL',
'label' => $this->l('Email'),
),
array(
'type' => 'password',
'name' => 'CARGO_ACCOUNT_PASSWORD',
'label' => $this->l('Password'),
),
),
'submit' => array(
'title' => $this->l('Save'),
),
),
);
}
/**
* Set values for the inputs.
*/
protected function getConfigFormValues()
{
return array(
'CARGO_LIVE_MODE' => Configuration::get('CARGO_LIVE_MODE', true),
'CARGO_ACCOUNT_EMAIL' => Configuration::get('CARGO_ACCOUNT_EMAIL', 'contact#prestashop.com'),
'CARGO_ACCOUNT_PASSWORD' => Configuration::get('CARGO_ACCOUNT_PASSWORD', null),
);
}
/**
* Save form data.
*/
protected function postProcess()
{
$form_values = $this->getConfigFormValues();
foreach (array_keys($form_values) as $key) {
Configuration::updateValue($key, Tools::getValue($key));
}
}
/**
* Add the CSS & JavaScript files you want to be loaded in the BO.
*/
public function hookBackOfficeHeader()
{
if (Tools::getValue('module_name') == $this->name) {
$this->context->controller->addJS($this->_path.'views/js/back.js');
$this->context->controller->addCSS($this->_path.'views/css/back.css');
}
}
/**
* Add the CSS & JavaScript files you want to be added on the FO.
*/
public function hookHeader()
{
$this->context->controller->addJS($this->_path.'/views/js/front.js');
$this->context->controller->addCSS($this->_path.'/views/css/front.css');
}
This is my code under hookActionOrderStatusPostUpdate function :
public function hookActionOrderStatusPostUpdate($params)
{
if ($params['newOrderStatus']->id == 6) {
$order = new Order((int)$params['id_order']);
$address = new Address((int)$order->id_address_delivery);
$country = new Country((int)($address->id_country));
$state = new State((int)($address->id_state));
$message = new Message((int)($order->id_message));
$Products = $order->getProducts();
$tel_cl = $address->phone;
$nom_prenom_cl = $address->lastname . ' ' . $address->firstname;
$ville_cl = $country->name;
$delegation_cl = $state->name;
$adresse_cl = $address->address1 . ' ' . $address->address2;
$tel_2_cl = $address->phone_mobile;
$libelle = '';
$nb_piece = 0;
foreach ($Products as $product) {
$libelle .= $product['product_name'] . '<br/>';
$nb_piece += $product['product_quantity'];
}
$cod = $order->total_paid;
$remarque = $message->message;
$Url_str = 'http://admin.cargotunisie.com/cargo_api/set_colis_cargo_get.php?id=1&tel_cl='.$tel_cl.'&nom_prenom_cl='.$nom_prenom_cl.'&ville_cl='.$ville_cl.'&delegation_cl='.$delegation_cl.'&adresse_cl='.$adresse_cl.'&tel_2_cl='.$tel_2_cl.'&libelle='.$libelle.'&cod='.$cod.'&nb_piece='.$nb_piece.'&remarque='.$remarque;
$json = Tools::file_get_contents($Url_str);
$result = json_decode($json);
}
}
}
It could be due to several things.
First: make sure the hook is hooked.
Go to Design > Positions > Then add new hook
Choose your module's name and check if you can select the hook actionOrderStatusPostUpdate. If you can, then it means it was unhooked.
This happens more than we would like, and sometimes you can get crazy until you found it
If that doesn't work you can try this (only if is not on a production site). If it is, just wrap it by using an if that checks if it's from your IP.
Add Tools::dieObject($params); at the beginning of the function.
Then change the an order and check the results. You should see a user friendly list of the values stored in $params.
Make it sure the $params['newOrderStatus'] exists and $params['newOrderStatus']->id is an object.
Also, it should be pretty obvious, but make sure the order ID which are you doing the tests is 6.
With that you should be able to have a general clue of what may be happening.

HelperList action 'delete' does not receive the ID

I've created a list which is fully populated with records from database. I'd like to add a button 'delete' in order to delete records on demand. The button appears, but whenever it makes a request, it does not have an ID of the record I want to delete. The URL looks like this:
controller=AdminModules&configure=estimateddelivery&=&deleteestimateddelivery&token=6d1625ddf520e0bf8d2c43bea84f21d3
There is a &=& which if I understand correctly should be populated with something like &id=10&. I am not sure what the problem is or where to look at. I've check code examples of similar functionalities and it looks like I am doing everything the same way.
public function renderList()
{
$this->$fields_list = [
'id_estimateddelivery' => [
'title' => $this->l('ID'),
'type' =>'text',
],
'from' => [
'title' => $this->l('Delivery period from')
],
'to' => [
'title' => $this->l('Delivery period to')
],
'countries' => [
'title' => $this->l('Countries applicable'),
'type' => 'text'
]
];
$helper = new HelperList();
$helper->module = $this;
$helper->shopLinkType = '';
$helper->simple_header = true;
$helper->idientifier = 'id_estimateddelivery';
$helper->actions = [
'delete'
];
$helper->show_toolbar = false;
$helper->title = $this->l('List of created estimated deliveries');
$helper->table = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
return $helper->generateList($this->getEstimatedDeliveries(), $this->$fields_list);
}
public function deleteEstimatedDelivery()
{
return Db::getInstance()->execute('DELETE FROM '. _DB_PREFIX_ .'estimateddelivery WHERE `id_estimateddelivery` = '. (int)Tools::getValue('id_estimateddelivery'));
}
else if(Tools::isSubmit('delete' . $this->name))
{
if(!$this->deleteEstimatedDelivery())
$output . $this->displayError($this->l('An error occured during link deletion'));
else
$output . $this->displayConfirmation($this->l('The estimated delivery has been deleted'));
}
Even though there was no error message, the code line: $helper->idientifier = 'id_estimateddelivery'; had a typo. Should have been identifier.

prestashop - Display status of order in AdminStats

I want the status order to display at AdminStats. I created the file override/controllers/admin/AdminStatsController.php:
<?php // Check order status in Stats Dashboard BO class AdminStatsController extends AdminStatsControllerCore {
public function __construct() {
parent::__construct();
$this->fields_list['order_statuses'] = array('title' => $this->l('Order Status');
}
}
But when I go to AdminStats, a blank page shows up (see image below).
Any suggestions?
EDIT: this is not the solution in respect to the question asked.
I'd to do the exact same thing. I did it something like this, but it was AdminOrdersController but it's pretty much the same. Here it is,
// override/controllers/admin/AdminStatsController.php
<?php
public function __construct() {
parent::__construct();
$this->fields_list = array_merge($this->fields_list, [
'order_statuses' => [
'title' => $this->l('Order Status'),
'align' => 'text-center',
'callback' => 'orderStatusFunction', // yes, a callback to get a piece of UI back, a button maybe
'orderby' => false, // or true, anything you'd like
'search' => false,
'remove_onclick' => true,
]
]);
}
}
Now the callback
<?php
public function orderStatusFunction($row_number, $row_data) // row_data like date, order, customer, etc
{
/* do stuff with data and assign to your template */
$view = _PS_MODULE_DIR_ . 'path/to/view/file/view.tpl';
$html = $this->context->smarty->createTemplate($view, $this->context->smarty)->fetch();
return $html;
}
Let me know if you've any confusion, or if it didn't work out.

Prestashop 1.7 - Overriding module class

i try to overriding a module in my custom themes, so I have copy past the original folder (from module folder in my themes > themename > modules folder)
but its not working
I have in my module folder from my theme :
ps_sharebuttons > views
and
ps_sharebuttons > ps_sharebuttons.php
which contains
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class Ps_SharebuttonsOverride extends Ps_Sharebuttons
{
public function renderWidget($hookName, array $params)
{
var_dump($params);
exit;
$key = 'ps_sharebuttons|' . $params['product']['id_product'];
if (!empty($params['product']['id_product_attribute'])) {
$key .= '|' . $params['product']['id_product_attribute'];
}
if (!$this->isCached($this->templateFile, $this->getCacheId($key))) {
$this->smarty->assign($this->getWidgetVariables($hookName, $params));
}
return $this->fetch($this->templateFile, $this->getCacheId($key));
}
public function getWidgetVariables($hookName, array $params)
{
if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'product') {
return;
}
$product = $this->context->controller->getProduct();
if (!Validate::isLoadedObject($product)) {
return;
}
$social_share_links = [];
$sharing_url = addcslashes($this->context->link->getProductLink($product), "'");
$sharing_name = addcslashes($product->name, "'");
$image_cover_id = $product->getCover($product->id);
if (is_array($image_cover_id) && isset($image_cover_id['id_image'])) {
$image_cover_id = (int)$image_cover_id['id_image'];
} else {
$image_cover_id = 0;
}
$sharing_img = addcslashes($this->context->link->getImageLink($product->link_rewrite, $image_cover_id), "'");
if (Configuration::get('PS_SC_FACEBOOK')) {
$social_share_links['facebook'] = array(
'label' => $this->trans('Share', array(), 'Modules.Sharebuttons.Shop'),
'class' => 'facebook',
'url' => 'http://www.facebook.com/sharer.php?u='.$sharing_url,
);
}
if (Configuration::get('PS_SC_TWITTER')) {
$social_share_links['twitter'] = array(
'label' => $this->trans('Tweet', array(), 'Modules.Sharebuttons.Shop'),
'class' => 'twitter',
'url' => 'https://twitter.com/intent/tweet?text='.$sharing_name.' '.$sharing_url,
);
}
if (Configuration::get('PS_SC_GOOGLE')) {
$social_share_links['googleplus'] = array(
'label' => $this->trans('Google+', array(), 'Modules.Sharebuttons.Shop'),
'class' => 'googleplus',
'url' => 'https://plus.google.com/share?url='.$sharing_url,
);
}
if (Configuration::get('PS_SC_PINTEREST')) {
$social_share_links['pinterest'] = array(
'label' => $this->trans('Pinterest', array(), 'Modules.Sharebuttons.Shop'),
'class' => 'pinterest',
'url' => 'http://www.pinterest.com/pin/create/button/?media='.$sharing_img.'&url='.$sharing_url,
);
}
return array(
'social_share_links' => $social_share_links,
);
}
}
But prestashop still use the orignal file module because i get this error :
'Undefined index: product', '/home/xxxxxxxx/www/modules/ps_sharebuttons/ps_sharebuttons.php',
I've already clear cache
Thanks for help
Ok im stupid, the override view goes to theme > module folder but the class should be in override > module folder

Prestashop: How to filter in HelperList

Hello I try to filter a List in the Backoffice. It shows the filter, it also saves it after clicking on search, but nothing is happening. Same with pagination.
$schueler = $this->getAllSchuelerbyDiplom($id_diplom);
$diplom_name = $this->getDiplomNamebyID($id_diplom);
$fields_list = array(
'id_schueler' => array(
'title' => 'ID',
'align' => 'center',
'class' => 'fixed-width-xs',
'search' => true),
'customer_name' => array(
'title' => $this->l('ID Customer')),
'id_gruppe' => array(
'title' => $this->l('ID Gruppe')),
'name' => array(
'title' => $this->l('Name'),
'filter_key' => 'name'.$diplom_name),
'vorname' => array(
'title' => $this->l('Vorname')),
'punkte' => array(
'title' => $this->l('Punkte')),
'bestanden' => array(
'title' => $this->l('Bestanden'),
'active' => 'toggle',
'class' => 'fixed-width-xs',
'type' => 'bool'),
'date_added' => array(
'title' => $this->l('Datum'),
'class' => 'fixed-width-xs',
'type' => 'date'),
);
$helper = new HelperList();
$helper->table = 'no-idea-what-this-is-for';
$helper->title = $diplom_name;
$helper->shopLinkType = '';
$helper->actions = array('view', 'edit', 'delete');
$helper->listTotal = count($schueler);
$helper->identifier = 'id_schueler';
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name .'&diplom_name=' . $diplom_name;
return $helper->generateList($schueler, $fields_list);
What is wrong with my code? What is $helper->table for? I tried different things there, but nothing helps...
EDIT
public function getAllSchuelerbyDiplom($id_diplom) {
$query = new DbQuery();
$query->select('s.*, CONCAT(c.firstname,\' \',c.lastname) AS customer_name');
$query->from($this->table_name.'_schueler', 's');
$query->leftJoin('customer', 'c', 's.id_customer = c.id_customer');
$query->where('s.id_diplom = ' . (int)$id_diplom);
return Db::getInstance()->ExecuteS($query);
}
The problem is that HelperList object itself will only display filters being used but won't filter the actual data list for you.
In your $this->getAllSchuelerbyDiplom($id_diplom); method I assume you execute SQL query to retrieve all rows, however you need modify it to account for any filters, paginations (page number and rows per page) or ordering. You have to check GET/POST values or values set in cookie to detect them.
$helper->table sets the table name and list actions are prepended with that name so they are distinct from any other lists you might have on the page.
Edit:
Example of setting pagination and page
public function getPage()
{
// $tableName must be equal to what you set in $helper->table
// Check if page number was selected and return it
if (Tools::getIsset('submitFilter'.$tableName)) {
return (int)Tools::getValue('submitFilter'.$tableName);
}
else {
// Check if last selected page is stored in cookie and return it
if (isset($this->context->cookie->{'submitFilter'.$tableName})) {
return (int)$this->context->cookie->{'submitFilter'.$tableName};
}
else {
// Page was not set so we return 1
return 1;
}
}
}
public function getRowsPerPage()
{
// $tableName must be equal to what you set in $helper->table
// Check if number of rows was selected and return it
if (Tools::getIsset($tableName. '_pagination')) {
return (int)Tools::getValue($tableName. '_pagination');
}
else {
// Check if number of rows is stored in cookie and return it
if (isset($this->context->cookie->{$tableName. '_pagination'})) {
return (int)$this->context->cookie->{$tableName. '_pagination'};
}
else {
// Return 20 rows per page as default
return 20;
}
}
}
public function getAllSchuelerbyDiplom($id_diplom) {
$query = new DbQuery();
$query->select('s.*, CONCAT(c.firstname,\' \',c.lastname) AS customer_name');
$query->from($this->table_name.'_schueler', 's');
$query->leftJoin('customer', 'c', 's.id_customer = c.id_customer');
$query->where('s.id_diplom = ' . (int)$id_diplom);
// Limit the result based on page number and rows per page
$query->limit($this->getRowsPerPage(), ($this->getPage() - 1) * $this->getRowsPerPage());
return Db::getInstance()->ExecuteS($query);
}
You can place a p(Tools::getAllValues()); d($this->context->cookie->getAll(); after you generate a list then set a filter in your list and it will show you all the variables you need to create filters and ordering.