[Solved] Journal 2 Product Grid changes disappear after interaction
Posted: Thu Nov 08, 2018 8:00 pm
Working with OC 2.0.1.1 and the Journal 2 template.
I want to display bulk order discounts in the product grid, so I modified controller/product/category.php and view/.../product/category.tpl.
When looking at a product category, it works fine at first. Then when I change anything in the product filter of the grid, the grid reloads and all bulk discounts are gone. Does anyone have a solution for this?
Here's my code:
controller/product/category.php
view/.../product/category.tpl
I want to display bulk order discounts in the product grid, so I modified controller/product/category.php and view/.../product/category.tpl.
When looking at a product category, it works fine at first. Then when I change anything in the product filter of the grid, the grid reloads and all bulk discounts are gone. Does anyone have a solution for this?
Here's my code:
controller/product/category.php
Code: Select all
$discounts_data = $this->model_catalog_product->getProductDiscounts($result['product_id']);
$discounts = array();
foreach ($discounts_data as $discount) {
$discounts[$discount['product_id']] = array(
'quantity' => $discount['quantity'],
'price' => $this->currency->format($this->tax->calculate($discount['price'], $result['tax_class_id'], $this->config->get('config_tax')))
);
}
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'discount' => (!empty($discounts[$result['product_id']]) ? $discounts[$result['product_id']] : array()),
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
);
Code: Select all
<?php echo "<b>" . $product['product_id'] . "</b> | ";
if ($product['discount']['price']) {
echo "<span style='color: red;'>" . $text_bulk_discount . $product['discount']['price'] . "</span>";
}
else {
echo $product['price'];
}
?>