I know this is an old post, but im using 2.1 and this is how ive done it.
There may be bugs here because its stripped out a much more complex module i am building. I'm adding product states (liquid, solid) into the system - (I will be uploading that to the market place at some point, but this is free small piece is free to use as is. I might add this too later).
Firstly i copied an admin localisation weight class method into a new front end localisation display weight model.
catalog/model/localisation/display_weight.php
Code: Select all
class ModelLocalisationDisplayWeight extends Model {
public function getWeightClass($weight_class_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wc.weight_class_id = '" . (int)$weight_class_id . "' AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
return $query->row;
}
}
Next I made a vqmod xml file.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Display Weight</id>
<vqmver>2.6</vqmver>
<version>1.0</version>
<author>Chris Serella</author>
<file path="catalog/language/*/product/" name="product.php">
<operation error="log">
<search><![CDATA[ignores this search but the element is required]]></search>
<add position="bottom"><![CDATA[$_['text_weight'] = "Weight:";]]></add>
</operation>
</file>
<file path="catalog/controller/product/" name="product.php">
<operation error="log">
<search><![CDATA[$data['text_loading'] = $this->language->get('text_loading');]]></search>
<add position="after"><![CDATA[$data['text_weight'] = $this->language->get('text_weight');]]></add>
</operation>
<operation error="log">
<search><![CDATA[$data['review_status'] = $this->config->get('config_review_status');]]></search>
<add position="before"><![CDATA[ if ($product_info['weight']) {
$data['product_weight'] = round($product_info['weight'], 2);
$this->load->model('localisation/display_weight');
$data['weight_sym'] = $this->model_localisation_display_weight->getWeightClass($product_info['weight_class_id']);
}]]></add>
</operation>
</file>
<file path="catalog/model/catalog/" name="product.php">
<operation error="log">
<search><![CDATA['viewed' => $query->row['viewed']]]></search>
<add position="iafter"><![CDATA[,
'product_weight' => $query->row['weight'],
'product_weight_class_id' => $query->row['weight_class_id'],
]]></add>
</operation>
</file>
<file path="catalog/view/theme/default/template/product/" name="product.tpl">
<operation error="log">
<search><![CDATA[<li><?php echo $text_model; ?> <?php echo $model; ?></li>]]></search>
<add position="after"><![CDATA[<li><?php echo $text_weight; ?> <?php echo $product_weight . $weight_sym['unit']; ?></li> ]]></add>
</operation>
</file>
</modification>
I hope this helps somebody out, I have some experience coding, but don't do much these days, I posted this back here because thread pointed me in the right direction. You will notice its compatible with your admin localisation of weight classes so they will be picked up in the system language automatically.
Make your own adjustment to $text_weight in the first file block, so long as the file exists it will automatically add that line in all languages. you can add separate blocks if you need full translations.
Oh one final note you will need VQMOD, or you can convert the file to be ocmod compatible and create the archive for upload with all the needed stuff which ever suits you.