I have to show the reduced price of the product in the product listing.
I have created 2 groups of standard users and VIP users. The VIP group enjoys a price discount, I want this price to be seen in the product list so that I do not enter the product and check the price. I made quite unsuccessful attempts and could not show it. Can anyone tell me where i am wrong.
I used the following:
admin/model/catalog/product.php
Code: Select all
public function getProductDiscounts ($ product_id) {
$ query = $ this-> db-> query ("SELECT * FROM". DB_PREFIX. "product_discount WHERE product_id = '". (int) $ product_id. "' ORDER BY quantity, priority, price");
return $ query-> rows;
}
I put these few lines of code in the protected function getList
Code: Select all
$this->load->model('customer/customer_group');
$data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups();
if (isset($this->request->post['product_discount'])) {
$discounts = $this->request->post['product_discount'];
} elseif (isset($this->request->get['product_id'])) {
$discounts = $this->model_catalog_product->getDiscountsProduct($this->request->get['product_id']);
} else {
$discounts = array();
}
$data['product_discounts'] = array();
foreach ($discounts as $discount) {
$data['discounts'][] = array(
'customer_group_id' => $product_discount['customer_group_id'],
'quantity' => $product_discount['quantity'],
'priority' => $product_discount['priority'],
'price' => $product_discount['price']
//'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency'])
);
}
Code: Select all
<tbody>
<?php if ($products) { ?>
<?php foreach ($products as $product) { ?>
<tr>
<td class="text-center"><?php if (in_array($product['product_id'], $selected)) { ?>
<input type="checkbox" name="selected[]" value="<?php echo $product['product_id']; ?>" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="selected[]" value="<?php echo $product['product_id']; ?>" />
<?php } ?></td>
<td class="text-center"><?php if ($product['image']) { ?>
<img src="<?php echo $product['image']; ?>" alt="<?php echo $product['name']; ?>" class="img-thumbnail" />
<?php } else { ?>
<span class="img-thumbnail list"><i class="fa fa-camera fa-2x"></i></span>
<?php } ?></td>
<td class="text-left"><?php echo $product['name']; ?></td>
<td class="text-left"><?php echo $product['sku']; ?></td>
<td class="text-left"><?php echo $product['model']; ?></td>
<td class="text-right"><?php if ($product['special']) { ?>
<span style="text-decoration: line-through;"><?php echo $product['price']; ?></span><br/>
<div class="text-danger"><?php echo $product['special']; ?></div>
<?php } else { ?>
<?php echo $product['price']; ?>
<?php } ?></td>
<td class="text-right"><?php if ($product_discounts) { ?>
<?php foreach ($product_discounts as $product_discount) { ?>
<?php echo $product_discount['quantity']; ?><?php echo $text_discount; ?><?php echo $product_discount['price']; ?>
<?php } ?>
<?php } ?></td>
<td class="text-right"><?php if ($product['quantity'] <= 0) { ?>
<span class="label label-warning"><?php echo $product['quantity']; ?></span>
<?php } elseif ($product['quantity'] <= 5) { ?>
<span class="label label-danger"><?php echo $product['quantity']; ?></span>
<?php } else { ?>
<span class="label label-success"><?php echo $product['quantity']; ?></span>
<?php } ?></td>
<td class="text-left"><?php echo $product['status']; ?></td>
<td class="text-right"><a href="<?php echo $product['edit']; ?>" data-toggle="tooltip" title="<?php echo $button_edit; ?>" class="btn btn-primary"><i class="fa fa-pencil"></i></a></td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td class="text-center" colspan="8"><?php echo $text_no_results; ?></td>
</tr>
<?php } ?>
</tbody>
the result is blank fields.
Some know where I am wrong and what needs to be done.
Тhanks!