Jump to content

SQL Query AdminMyModuleController $this->table


Recommended Posts

I'm trying to get a table from the categories. I would need the ID and the Name combined from table ps_category & ps_category_lang.

I found this structure in order to add the function on the AdminMyModuleController.

My knowledge in SQL are limitated and I don't get how to strudcutre the query. I also don't understand clearly the prefixe c & cl.

 

	 protected function categeoryList()
    {
        $this->table = 'category';
        $this->identifier = '`id_category`';
        $this->_select = 'c.`id_category`, `name`, `description`' ;

		$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
			ON (c.`id_category` = cl.`id_category`)
			AND (`id_lang` = '.(int)$this->context->language->id.')';

		$this->fields_list = array(
            `id_category` => array(
                'title' => $this->l('ID'),
                'align' => 'center',
            ),
            'name' => array(
                'title' => $this->l('Outlet Name'),
                'align' => 'center',
                'havingFilter' => true
            ),
        );
    }

Here is the error massage :

[PrestaShopDatabaseException]

Champ 'c.id_category' inconnu dans field list

SELECT SQL_CALC_FOUND_ROWS  a.*
, c.`id_category`, `id_parent`, `active`, `name`, `description`, `position`
FROM `liloshop_category` a 

 LEFT JOIN `liloshop_category_lang` cl
			ON (c.`id_category` = cl.`id_category`)
			AND (`id_lang` = 1) 
 WHERE 1 

 ORDER BY id_configuration ASC  LIMIT 0, 50

any idea how to get the correct syntax ?

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