Found a file responsible for displaying the price, under its line or in it with a fraction I want to insert a code that displays the weight of the product in grams. Tell me, please, what should be the code. File path:: app \ design \ frontend \ rwd \ default \ template \ catalog \ product \ price.phtml

<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>"> <?php echo $_coreHelper->currency($_price + $weeeAmountToDisplay, true, true) ?> </span> 

enter image description here

  • $ product-> getWeight () But I don’t see the actual product object in your example. - Invision
  • Unfortunately, I do not understand this ... Logically, I found a line that displays the price of the product and, in theory, I should write something similar under it that only displays the weight. Perhaps in the hml file you will need to add a block. But, in principle, this is a price block, add a grammar there. And in the example, the code displays the price for each product. - Sylon
  • Wrong in the template with the price to thrust something else. - danil
  • The fact is that, for example, in restaurants, the price goes immediately with a gram. - Sylon

1 answer 1

 <span class="regular-weight"> <?php $pro=Mage::getModel('catalog/product')->load($_product->getEntityId()); ?> <?php echo $pro->getWeight(); ?><?php echo $this->__('гр');?> </span> 
  • 1. See how the number of database queries will increase. This code runs in a loop and will increase the page load time. 2. $ this -> __ ('gr'); - This is the method that is responsible for translations. In order to translate, you need to use csv translation files. - danil