i have this code in an observer.php :


class Moh3n_Attvaluecopier_Model_Observer

public function  copyAttribute($observer){


        $_product = $observer->getProduct();
        $_productid = $_product->getId();
        $productModel = Mage::getModel('catalog/product');
        $loadCurrentProduct = $productModel->load($_productid);

it copies the weight attribute value into general_weight attribute without decimals.

i want to add a value like (KG) to general_weight right after copied value. i want general_weight to show this way: 1000 KG

how to do that?

1 Answer 1


Assuming you are saving it as a string, just do this:

$weight = intval($loadCurrentProduct->getWeight());
$gw = (string)$weight. " KG";

If you need to save it as an integer for comparison or something, you could add the KG when outputting the value in the template, or write a custom getter for general_weight in your model that gives you

return $value . " KG";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.