i want to show popular posts in cart page. i try but i can't.
i add this code, controller > checkout > cart.php
Code: Select all
$this->load->model('catalog/product');
$data['products'] = array();
if (!$setting['limit']) {
$setting['limit'] = 4;
}
$filter_data = array(
'sort' => 'p.date_added',
'order' => 'DESC',
'start' => 0,
'limit' => $setting['limit']
);
$oresults = $this->model_catalog_product->getPopularProducts($filter_data);
if ($oresults) {
foreach ($oresults as $oresult) {
if ($oresult['image']) {
$image = $this->model_tool_image->resize($oresult['image'], $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($oresult['price'], $oresult['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$oresult['special']) {
$special = $this->currency->format($this->tax->calculate($oresult['special'], $oresult['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$oresult['special'] ? $oresult['special'] : $oresult['price'], $this->session->data['currency']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = $oresult['rating'];
} else {
$rating = false;
}
$data['products'][] = array(
'product_id' => $oresult['product_id'],
'thumb' => $image,
'name' => $oresult['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($oresult['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $oresult['product_id'])
);
}
return $this->load->view('extension/module/latest', $data);
} else {
return '-';
}
Code: Select all
{% for oresult in oresults %}
<div class="product-layout product-list col-xs-12 col-md-4">
<div class="product-thumb">
<div class="image"><a href="{{ oresult.href }}"><img src="{{ oresult.thumb }}" alt="{{ oresult.name }}" title="{{ oresult.name }}" class="img-responsive" /></a></div>
<div>
<div class="caption">
<h4><a href="{{ oresult.href }}">{{ oresult.name }}</a></h4>
<p>{{ oresult.description }}</p>
{% if oresult.price %}
<p class="price">
{% if not oresult.special %}
{{ oresult.price }}
{% else %} <span class="price-new">{{ oresult.special }}</span> <span class="price-old">{{ oresult.price }}</span>
{% endif %}
</p>
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}