Matthieu_ Posted August 22, 2017 Share Posted August 22, 2017 Hi, i am creating a module on Presta 1.7.2, i would like to add a table of products in the admin product section (with the hook displayAdminProductsExtra). This is a simplified version of my code public function hookDisplayAdminProductsExtra($params) { $products = MyModel::getProducts(); $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = true; $helper->identifier = 'id'; $helper->show_toolbar = true; $helper->title = 'HelperList'; $helper->table = $this->name . '_mytable'; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; return $helper->generateList($products, array( 'id' => array( 'title' => 'ID', 'type' => 'text' ), 'name' => array( 'title' => 'Nom', 'type' => 'text' ) )); } It generate the following error : Twig_Error_Runtime in form.html.twig line 951: An exception has been thrown during the rendering of a template ("Unable to load template file 'helpers/list/list_header.tpl'"). The template file exists, i tried to do some debugging in HelperList class, but no luck so far. Anyone can help ? 1 Link to comment Share on other sites More sharing options...
seb94 Posted May 22 Share Posted May 22 (edited) Hi, is somebody find a response ? I have the same problem and i'm using PS1.7.8.10 In fact I try to generate the list by a controller and after give the result to the hook but there is problems with ajax fields and bootstrap... <?php use PrestaShopBundle\Entity\Repository\TabRepository; if (!defined('_PS_VERSION_')) exit; require_once _PS_ROOT_DIR_ . '/modules/products_features_manager/classes/ProductState.php'; require_once _PS_ROOT_DIR_ . '/modules/products_features_manager/classes/CaracteristiqueRule.php'; require_once _PS_ROOT_DIR_ . '/modules/products_features_manager/controllers/admin/ProductFeaturesController.php'; class Products_Features_Manager extends Module { ... public function hookDisplayAdminProductsMainStepLeftColumnBottom($params){ $controller = new ProductFeaturesController(); $html = $controller->generateForHooks($params['id_product']); return $html; } } <?php if (!defined('_PS_VERSION_')) exit; // You can now access this controller from /your_admin_directory/index.php?controller=AdminMyAdminController require_once _PS_ROOT_DIR_ . '/modules/products_features_manager/classes/ProductState.php'; require_once _PS_ROOT_DIR_ . '/modules/products_features_manager/classes/CaracteristiqueRule.php'; class ProductFeaturesController extends ModuleAdminController { /** * @var array */ public $product_list; public $fields_list; public function __construct() { $this->className = 'ProductFeatures'; $this->lang = true; $this->deleted = false; $this->colorOnBackground = false; $this->bootstrap = true; parent::__construct(); } public function generateForHooks($id_product) { $fields_list = [ 'feature_name' =>[ 'title' => 'Feature Name', 'type' => 'text', ], 'category_name' =>[ 'title' => 'Category', 'type' => 'text', 'orderby' => true, // If true, list will be alphabetically ordered using this column values (optional, default false). ], 'follow_rule' =>[ 'title' => 'Follow Rule', 'type' => 'bool', 'filter_type' => 'bool', // Specify the value format when used in the filter where clause. //'orderby' => true, // If true, list will be alphabetically ordered using this column values (optional, default false). 'icon' => array( // If set, an icon will be displayed with icon key matching the field value. 0 => 'disabled.gif', // Used in combination with type == bool (optional). 1 => 'enabled.gif', 'default' => 'disabled.gif' ), 'ajax' => true // if the type is bool, you use ajax ] ]; $html=""; $productState = new ProductState($id_product); $result = $productState->getArrayAllRulesForHooks(); error_log(print_r($result,true)); $helper_list= new HelperList(); $helper_list->module = $this->module; $helper_list->title = 'Category rules for this product'; $helper_list->no_link = true; $helper_list->show_toolbar = true; $helper_list->simple_header = true; $helper_list->currentIndex = ModuleAdminController::$currentIndex; $helper_list->token = Tools::getAdminTokenLite('AdminProduct'); $html .= $helper_list->generateList($result, $fields_list); return $html; } } does anyone have an other solution or can help me to fix problems with bootstrap and ajax ? Thanks ! Edited May 22 by seb94 (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now