jmauclair Posted July 15, 2021 Share Posted July 15, 2021 Hi guys ! I'm working on a new module which allow to associate product to part of cars. I'm facing a little issue, on every controllers I make, I use the fields_list, but when I'm using the search box, I doesn't filter the results as you can see on the following screenshot. Here is my controller code : //*** is to hide sensitive informations <?php require_once(_PS_MODULE_DIR_ . '***Filter/classes/carBulbsAssociation.php'); class Admin***FilterCarBulbsAssociationController extends ModuleAdminController { public function __construct() { parent::__construct(); // Base $this->bootstrap = true; // use Bootstrap CSS $this->table = '***filter_carbulb_association'; // SQL table name, will be prefixed with _DB_PREFIX_ $this->identifier = 'id_***Filter_carbulb_association'; // SQL column to be used as primary key $this->className = 'CarBulbsAssociation'; // PHP class name $this->allow_export = true; // allow export in CSV, XLS.. $this->addRowAction('edit'); $this->addRowAction('view'); $this->addRowAction('delete'); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash')); $this->_defaultOrderBy = 'a.id_***Filter_carbulb_association'; // the table alias is always `a` $this->_defaultOrderWay = 'ASC'; $this->_select = 'a.id_***Filter_carbulb_association as `carBulbAssocID`, cbt.type_name as `bulbType`, prod.reference as `prodReference`, prodl.name as `prodName`, prod.id_product as `prodID`'; $this->_join = ' LEFT JOIN `' . _DB_PREFIX_ . '***filter_carbulb_type` cbt ON a.id_***Filter_carbulb=cbt.id_***Filter_carbulb_type LEFT JOIN `' . _DB_PREFIX_ . 'product` prod ON a.id_***Filter_product=prod.id_product LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` prodl ON prod.id_product=prodl.id_product; '; $this->fields_list = array( 'carBulbAssocID' => array('title' => 'Car Bulb ID'), 'bulbType' => array('title' => 'Bulb Type'), 'prodReference' => array('title' => 'Product Reference'), 'prodName' => array('title' => 'Product Name') ); $products = Product::getProducts($this->context->language->id, 0, 0, 'name', 'ASC', false, true); $this->fields_form = array( 'legend' => array( 'title' => 'Edit Bulb Association' ), 'input' => array( array('name' => 'bulbType', 'type'=>'text','label'=>'Bulb Type','required'=>true), array('name'=> 'prodID', 'label'=> 'Products', 'type'=>'select', 'required'=>true, 'options'=>array( 'query'=> $products, 'id' => 'id_product', 'name' => 'name' )) ), 'submit'=> array( 'title'=> $this->l('Save') ) ); } } Here is my class : //**** is to hide sensitive informations <?php class CarBulbsAssociation extends ObjectModel{ public $id_***Filter_carbulb_association; public $id_***Filter_carbulb; public $id_***Filter_product; public static $definition = array( 'table'=> '***filter_carbulb_association', 'primary' => 'id_***Filter_carbulb_association', 'fields'=> array( 'id_***Filter_carbulb_association' => array('type' => self::TYPE_INT, 'validate'=> 'isUnsignedInt', 'required'=> true ), 'id_***Filter_carbulb' => array('type' => self::TYPE_INT, 'validate'=> 'isUnsignedInt', 'required'=> true ), 'id_***Filter_product' => array('type' => self::TYPE_INT, 'validate'=> 'isUnsignedInt', 'required'=> true ), ) ); } ?> My class seems to be well define, I don't have any issues with that, I think that the issue is from : 'a.id_***Filter_carbulb_association as `carBulbAssocID`, cbt.type_name as `bulbType`, prod.reference as `prodReference`, prodl.name as `prodName`, prod.id_product as `prodID`'; In cause of the aliases, but after trying without aliases, I've got the same issue so I don't really know, if anybody already faced the same issue or similar, let me know ! Link to comment Share on other sites More sharing options...
jmauclair Posted July 15, 2021 Author Share Posted July 15, 2021 By the way, here is the SQL query : SELECT SQL_CALC_FOUND_ROWS a.* , a.id_***Filter_carbrand as `modelBrandID`, a.id_***Filter_carmodel as `modelID`, a.name as `carModelName`, a.category_id as `modelCatId`, cb.name as `carBrand`, kit.auxiliary_indicator , kit.daytime_running_light , kit.fog_light , kit.front_indicator , kit.high_beam , kit.license_plate, kit.low_beam, kit.parking_light, kit.rear_indicator , kit.rear_fog_light , kit.reversing_light , kit.side_indicator , kit.stoplight , kit.taillight FROM `miib_***filter_carmodel` a LEFT JOIN `miib_***filter_carbulb_kit` kit ON kit.id_***Filter_carmodel=a.id_***Filter_carmodel LEFT JOIN `miib_***filter_carbrand` cb ON cb.id_***Filter_carbrand=a.id_***Filter_carbrand; WHERE 1 AND cb.`name` LIKE '%Abarth%' ORDER BY a.`id_***Filter_carbrand` ASC LIMIT 0, 50 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