I have created a page where i want to show listing from database. i have follow the same steps to from this link which is working fine. but issue is that i can't loop data from database in my tpl file
. In tpl
file I show listing
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
</table>
please help me.
In custom-page.php before: $smarty->display(_PS_THEME_DIR_.'custom-page.tpl');
add:
$customer = CustomerCore::getCustomers();
$contact =array();
foreach ($customer as $c){
$id = AddressCore::getFirstCustomerAddressId($c['id_customer']);
$contact[] = new AddressCore($id);
}
$smarty->smarty->assign(array('contacts'=>$contact));
In custom-page.tpl insert:
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
{foreach $contacts as $contact}
<tr>
<td>{$contact->company}</td>
<td>{$contact->lastname} {$contact->firstname}</td>
<td>country</td>
</tr>
{/foreach}