Addon to show all customer connections in PrestaShop
Hello MilosIs there an addon or a setting in Pestashop to show all the customer connections ?it only shows the last 10, in database they are all there
Hello,
as i understand you are looking for something that will show more 'connections' here: https://i.imgur.com/ptG1RNV.png,
right ? If so - for what prestashop version? 1.6 or 1.7 ?
I do not have this kind of module, but i can guide you how to achieve this.
Case is very easy to follow.
- go to file /classes/Customer.php
- near line 870 you can find code like:
public function getLastConnections()
{
if (!$this->id) {
return array();
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_connections, c.date_add, COUNT(cp.id_page) AS pages, TIMEDIFF(MAX(cp.time_end), c.date_add) as time, http_referer,INET_NTOA(ip_address) as ipaddress
FROM `' . _DB_PREFIX_ . 'guest` g
LEFT JOIN `' . _DB_PREFIX_ . 'connections` c ON c.id_guest = g.id_guest
LEFT JOIN `' . _DB_PREFIX_ . 'connections_page` cp ON c.id_connections = cp.id_connections
WHERE g.`id_customer` = ' . (int) $this->id . '
GROUP BY c.`id_connections`
ORDER BY c.date_add DESC
LIMIT 10'
);
}
LIMIT 10
in code i shared above informs how many positions prestashop will display.- if you want to increase the number of entries this feature displays - just increase "10" to for example "50", as i show in modified code:
public function getLastConnections()
{
if (!$this->id) {
return array();
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_connections, c.date_add, COUNT(cp.id_page) AS pages, TIMEDIFF(MAX(cp.time_end), c.date_add) as time, http_referer,INET_NTOA(ip_address) as ipaddress
FROM `' . _DB_PREFIX_ . 'guest` g
LEFT JOIN `' . _DB_PREFIX_ . 'connections` c ON c.id_guest = g.id_guest
LEFT JOIN `' . _DB_PREFIX_ . 'connections_page` cp ON c.id_connections = cp.id_connections
WHERE g.`id_customer` = ' . (int) $this->id . '
GROUP BY c.`id_connections`
ORDER BY c.date_add DESC
LIMIT 50'
);
}
- save changes to modified file - and that's all.
- you mentioned that you want to display "all connections". How to achieve it? just remove LIMIT 10:
public function getLastConnections()
{
if (!$this->id) {
return array();
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_connections, c.date_add, COUNT(cp.id_page) AS pages, TIMEDIFF(MAX(cp.time_end), c.date_add) as time, http_referer,INET_NTOA(ip_address) as ipaddress
FROM `' . _DB_PREFIX_ . 'guest` g
LEFT JOIN `' . _DB_PREFIX_ . 'connections` c ON c.id_guest = g.id_guest
LEFT JOIN `' . _DB_PREFIX_ . 'connections_page` cp ON c.id_connections = cp.id_connections
WHERE g.`id_customer` = ' . (int) $this->id . '
GROUP BY c.`id_connections`
ORDER BY c.date_add DESC
'
);
}
Addon to show all customer connections in PrestaShop
Reviewed by VEKIA
on
Friday, February 08, 2019
Rating:
No comments