Answer the question
In order to leave comments, you need to log in
How to display the result of a function in a tpl (MVC) template?
Good people, tell me how to display the result of the function from the controller in the opencart tpl template:
Model:
public function getColorProduct($sku) {
$sql = "SELECT * FROM " . DB_PREFIX . "product GROUP BY sku = '{$sku}'";
$ColorProduct = array();
$query = $this->db->query($sql);
foreach ($query->rows as $result) {
$ColorProduct[$result['product_id']] = $this->getProduct($result['product_id']);
}
return $ColorProduct;
}
/*вот 78 строка*/ <?php if ($Color_Sku ) { ?>
<?Php foreach ($Color_Sku as $ColorSku) { ?>
<div class="color_div_sku_id">
<?Php echo $ColorSku['sku']; ?>
</div>
<?Php } ?>
<?Php } else { ?>
<div class="color_div_sku_id">
<p>No!</p>
</div>
<?Php } ?>
$Color_Sku = $this->model_catalog_product->getColorProduct($data['sku']);
var_dump($Color_Sku); //Массив заполнен
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question