Jump to content

ajouter le code postal dans la liste des clients dans le BO


Rdev

Recommended Posts

j'ai trouvé une solution

il faut ajouter ce code à la fin du $this->_select

, (
				SELECT b.postcode FROM '._DB_PREFIX_.'address b
				WHERE b.id_customer = a.id_customer
				LIMIT 1
		) as postcode ';

 

et ajouter ce code entre l'email et l'age

'postcode' => array('title' => $this->l('Postcode'), 'width' => 32),

le code final est :

$this->_select = '(YEAR(NOW()) - YEAR(birthday)) as age, (
		SELECT c.date_add FROM '._DB_PREFIX_.'guest g
		LEFT JOIN '._DB_PREFIX_.'connections c ON c.id_guest = g.id_guest
		WHERE g.id_customer = a.id_customer
		ORDER BY c.date_add DESC
		LIMIT 1
	) as connect, (
		SELECT b.postcodeFROM '._DB_PREFIX_.'address b
		WHERE b.id_customer = a.id_customer
		LIMIT 1
	) as postcode';
$genders = array(1 => $this->l('M'), 2 => $this->l('F'), 9 => $this->l('?'));
$this->fieldsDisplay = array(
	'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
	'id_gender' => array('title' => $this->l('Gender'), 'width' => 25, 'align' => 'center', 'icon' => array(1 => 'male.gif', 2 => 'female.gif', 'default' => 'unknown.gif'), 'orderby' => false, 'type' => 'select', 'select' => $genders, 'filter_key' => 'a!id_gender'),
	'lastname' => array('title' => $this->l('Last Name'), 'width' => 80),
	'firstname' => array('title' => $this->l('First name'), 'width' => 60),
	'email' => array('title' => $this->l('E-mail address'), 'width' => 120, 'maxlength' => 19),
	'postcode' => array('title' => $this->l('Postcode'), 'width' => 32),
	'age' => array('title' => $this->l('Age'), 'width' => 30, 'search' => false),
	'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false),
	'newsletter' => array('title' => $this->l('News.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif'), 'orderby' => false),
	'optin' => array('title' => $this->l('Opt.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif'), 'orderby' => false),
	'date_add' => array('title' => $this->l('Registration'), 'width' => 60, 'type' => 'date'),
	'connect' => array('title' => $this->l('Connection'), 'width' => 60, 'type' => 'datetime', 'search' => false));

Link to comment
Share on other sites

  • 10 months later...

Bonjour radhia,

 

Merci pour ce code, je m'en suis servi et il fonctionne très bien.

J'aimerais l'améliorer pour rendre le champ "code postal" "cherchable".

J'ai ajouté un 'search' => true mais quand j'envoie une recherche j'ai une erreur 

  • Mauvaise requête SQL
    Unknown column 'postcode' in 'where clause'

 

Je comprends que le problème vient du fait que je fais un appel à un champ contenu dans une autre table que "customer" mais je ne vois pas trop comment déclarer la jointure ou expliquer à PS de chercher dans le champ postcode défini dans le controller.

 

As tu une idée ?

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