3

I have the weight. But I was interested in how to remove all the digits after the decimal point with her? Now, this situation... enter image description here I want it to be so. enter image description here And I have code in price.phtml

<span class="regular-weight"> <?php $pro=Mage::getModel('catalog/product')->load($_product->getEntityId()); ?>
                 <?php echo  $pro->getWeight(); ?><?php echo $this->__('grams');?>
            </span>
2

Try this :

<span class="regular-weight">
     <?php echo number_format($_product->getWeight())?><?php echo $this->__('grams');?>
</span>

OR

<span class="regular-weight">
     <?php echo round($_product->getWeight())?><?php echo $this->__('grams');?>
</span>
2
<span class="regular-weight"> <?php $pro=Mage::getModel('catalog/product')->load($_product->getEntityId()); ?>
    <?php    
        $weight = (float) $pro->getWeight();
        $formattedWeight = number_format($weight, 0, ',', '');
        echo sprintf("%s %s", $formattedWeight, $this->__('grams'));
    ?>
</span>
2
$_MyValue = $pro->getWeight();
if (is_numeric($_MyValue))
{
 $my_data_value = number_format((float)$_MyValue, 0, '.', '');
}
2

In database, weight attribute have backend_type set to decimal.

To change the decimal precision of attributes that have a backend_type set to decimal,

You have to change the type of value in this table :

catalog_product_entity_decimal

If you have not change yet, you should see :

decimal(12,4)

In your case, you have to replace with

decimal(12,0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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