Visualizar Discounts en Categorias
Posted: Thu Aug 22, 2024 6:14 am
Buenas, quiero listar los descuentos en la vista de categorias. Adjunto lo que estoy armando.
En catalog/controller/product/category.php
Dentro del for de productos
Agregue lo siguiente:
En: catalog/view/theme/default/template/product/category.twig
Antes de:
Agrego
El problema es que no se visualiza la cantidad ni el precio.. Solo se ve el bucle de "o mas"
En catalog/controller/product/category.php
Dentro del for de productos
Code: Select all
$results = $this->model_catalog_product->getProducts($filter_data);
foreach ($results as $result) {
Code: Select all
// AGREGADO
$discounts = $this->model_catalog_product->getProductDiscounts($result['product_id']);
$data['discounts'] = array();
foreach ($discounts as $discount) {
$data['discounts'][] = array(
'quantity' => $discount['quantity'],
'price' => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
);
}
// FIN AGREGADO
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(trim(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8'))), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'minimum' => $result['minimum'] > 0 ? $result['minimum'] : 1,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url),
'discounts' => $data['discounts'] // AGREGADO
);
En: catalog/view/theme/default/template/product/category.twig
Antes de:
Code: Select all
{% if product.rating %}
Code: Select all
{% if product.discounts %}
{% for discount in product.discounts %}
<hr>
{{ product.discounts.quantity }}{{ text_discount }}{{ product.discounts.price }}
{% endfor %}
{% endif %}
El problema es que no se visualiza la cantidad ni el precio.. Solo se ve el bucle de "o mas"