Jump to content

Edit History

seb94

seb94

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

image.thumb.png.40a8401fdbc3c4900f4ad7465f3ed02e.png

<?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 ! ;)

seb94

seb94

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

image.thumb.png.40a8401fdbc3c4900f4ad7465f3ed02e.png

<?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 fiw problems with bootstrap and ajax ?

Thanks ! ;)

×
×
  • Create New...