Page 1 of 1

Weight Setting

Posted: Thu Mar 19, 2009 2:26 pm
by lepe
(v.1.1.8 )

I would develop this part in my version, but in case you think is good idea I can post the changes...

All products have the "weight" value, however it is not displayed to the public. In some cases it may be desired, so I will add that option in the settings.

Re: Weight Setting

Posted: Wed Mar 25, 2009 10:28 am
by lepe
this also may apply for v.1.x.x (included 1.2.x):

Required changes to display "weight" in product details:

Modifications to: catalog/controller/product/product.php
(if you don't know where to add them, search similar lines):

Code: Select all

$this->data['text_weight'] = $this->language->get('text_weight'); 

$this->load->model('localisation/weight_class');
$weight_unit = $this->model_localisation_weight_class->getWeightUnit($product_info['weight_class_id']);
$this->data['weight'] = $product_info['weight'] . ' ' . $weight_unit;
Add in:
(for 1.2.x) catalog/view/theme/YOURTHEME/template/product/product.tpl
(for 1.1.x) catalog/view/template/product/product.tpl

Code: Select all

<tr>
<td><b><?php echo $text_weight; ?></b></td>
<td><?php echo $weight; ?></td>
</tr>
Create this file: catalog/model/localization/weight_class.php:

Code: Select all

<?php
class ModelLocalisationWeightClass extends Model {
    public function getWeightUnit($weight_class) {
            $query = $this->db->query("SELECT unit FROM weight_class WHERE weight_class_id = $weight_class AND language_id = '" . (int)$this->language->getId() . "'");
            return @$query->rows[0]["unit"];
    }
}
?>
I added the "@" to prevent any misconfiguration to display errors... in case of an error no unit will be displayed.

That's all...

Re: Weight Setting

Posted: Wed Mar 25, 2009 10:31 am
by lepe
I forgot also to include the language label in the last post:

Add in: catalog/language/english/product/product.php:

Code: Select all

$_['text_weight']        = 'Weight:';