Jump to content

[1.6.x] Module Controller - Listhelper Filter Not Working


Casper_O

Recommended Posts

I Have been trying to make a controller with listHelper to show and filter some custom table and finally i figured out how to get the sorting to work correctly, but filtering just dont want to play with me.

 

this is the top of my code so far, where i generate the listing:
 

class AdminBogportalenPricerulesController extends ModuleAdminController {

	public $available_fields;

	public function __construct()
	{
		
		$manufacturers = Manufacturer::getManufacturers(false, 0, true, false, false, false, true);
		foreach ($manufacturers as $manufacturer)
		{
			$manufacturers_list[$manufacturer['id_manufacturer']] = $manufacturer['name'];
		}
		
		$suppliers = Supplier::getSuppliers();
		foreach ($suppliers as $supplier)
		{
			$suppliers_list[(int)$supplier['id_supplier']] = $supplier['name'];
		}
		
		$this->bootstrap = true;
		$this->module = 'bogportalen';
		$this->className = 'BogportalenPricerules';
		$this->table = 'bogportalen_pricerules';
		$this->meta_title = $this->l('Bogportalen pricerules');
		$this->identifier = 'id_pricerule';
		$this->context = Context::getContext();
		parent::__construct();
		$this->fields_list = array(
			'id_pricerule' => array(
				'title' => $this->l('ID'),
				'align' => 'text-center',
				'class' => 'fixed-width-xs',
			),
			'isbn' => array(
				'title' => $this->l('isbn'),
			),
			'discountcategory' => array(
				'title' => $this->l('Discount category'),
				'filter_key' => 'a!discountcategory',
			),
			'distributor_name' => array(
				'title' => $this->l('Distributor'),
				'type' => 'select',
				'list' => $suppliers_list,
				'filter_key' => 's!id_supplier',
                'order_key' => 'distributor_name'
				//'filter_key' => 's\!id_supplier',
			),
			'publisher_name' => array(
				'title' => $this->l('Publisher'),
				'type' => 'select',
				'list' => $manufacturers_list,
				'filter_key' => 'm!id_manufacturer',
			),
			'adjustment' => array(
				'title' => $this->l('Adjustment'),
				'filter_key' => 'a!adjustment',
			),
			'rounding' => array(
				'title' => $this->l('Rounding'),
			),
			'status' => array(
				'title' => $this->l('status'),
				'active' => 'status',
				'type' => 'bool',
				'class' => 'fixed-width-xs',
				'align' => 'center',
				'filterBy' => false,
				'search' => false,
			),
		);
		
		
		$this->_select = '
				s.name as distributor_name,
				m.name as publisher_name';
				
		$this->_join = '
				LEFT JOIN '._DB_PREFIX_.'supplier s ON s.id_supplier = a.distributor
				LEFT JOIN '._DB_PREFIX_.'manufacturer m ON m.id_manufacturer = a.publisher';
				
		$this->_defaultOrderBy = 'id_pricerule';
		$this->_defaultOrderWay = 'ASC';
		
		parent::__construct();
		if (! $this->module->active)
			Tools::redirectAdmin($this->context->link->getAdminLink('AdminHome'));

	}

If i click one of the filters, the page reloads, the filter value fields are blank and i still see all entries.

 

Also i noticed that in SmartBlog module on Comment overview, if you filter they have a variable in the URL named: submitFiltersmart_blog_comment=1

I dont have this variable in my URL.

 

I have been reading the documentation for listHelper for days, but there is nothing helpfuld regarding filters

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