Now that You have stored the country_id
, You can simply load the concrete country based on that id when loading the reviews (for each review, respectively).
When the reviews are loaded from DB, in catalog/controller/product/product.php
in method review()
the array of results is looped through:
foreach ($results as $result) {
$this->data['reviews'][] = array(
'author' => $result['author'],
'text' => $result['text'],
'rating' => (int)$result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$review_total),
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}
Now You only need to load the country to get it's code for flag, so You could end up with something like this:
$this->load->model('localisation/country');
foreach ($results as $result) {
$country = $this->model_localisation_country->getCountry($result['country_id']);
$this->data['reviews'][] = array(
'author' => $result['author'],
'text' => $result['text'],
'rating' => (int)$result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$review_total),
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'flag' => strtolower($country['iso_code_2']) . '.png'
);
}
Now the flag
index should contain value like de.png
, gb.png
, fr.png
etc. Just make sure You type the right value to the flag images in the template and that You have the flag images with such a names...