2

I want to display products unit of measurement at the frontend. For that I have created weight_unit attribute in admin panel and I am adding it to products like gram, kilogram, liter, etc. But I can't show it at frontend. I use following code to display at frontend:

<?php echo $_product->getAttributeText('weight_unit'); ?> 

Still I am not getting proper show of product unit. Please can anyone suggest me how to show it? Is there any other methods to represent the product unit?

Alexandr Lazarev
  • 12,554
  • 4
  • 38
  • 47
Ashwini
  • 155
  • 9
  • proper show of product unit means what it is showing ? – Pankaj Pareek Sep 21 '15 at 11:16
  • Whatever weight & weight_unit I added at admin panel that should be displayed at product page(at frontend) before add to cart button – Ashwini Sep 21 '15 at 11:44
  • weight_unit selectbox attribute ? – Pankaj Pareek Sep 21 '15 at 11:47
  • no it is dropdown. I don't have idea what should keep so I kept it as dropdown??should I make it select box or keep it as it is? – Ashwini Sep 21 '15 at 11:51
  • Have you any idea? If yes then.. How to solve it..Please reply soon..? – Ashwini Sep 21 '15 at 12:26
  • @Ashwini Do you want to show weight_unit as drop down? Are you facing issue to display it on front end(listing page or product details page)? – Mukesh Sep 21 '15 at 12:32
  • @Muk..No I don't want to show it as dropdown in frontend.I know it should be possible by using custom option . Please read my above question carefully..I have added weight_unit attribute at admin side on add to product page. where I set it as drop down for it. – Ashwini Sep 21 '15 at 12:38

2 Answers2

0

You can use translation method to achieve this. You can find out that in following link.

https://magento.stackexchange.com/questions/6924/custom-attribute-ending

In this post, translation method and translation CSV files are used to achieve this. You can write your unit of measurement in CSV file and use attribute code in translation method.

Community
  • 1
  • 1
0

For display Weight and Weight unit on Product details page, you need to use the below code :

echo $_product->getWeight().' '.$_product->getAttributeText('weight_unit');

Please make sure Visible on Product View Page on Front-end set to yes for both attributes.

Pankaj Pareek
  • 3,806
  • 2
  • 31
  • 42
  • Yes I tried this way. But it is only static way to display at frontend. I want to change the price also as weight vary as per that price get update. – Ashwini Sep 22 '15 at 05:07
  • want to change the price also as weight vary .. Can you please more about this – Pankaj Pareek Sep 22 '15 at 05:10
  • I mean ,I want to show user friendly the weight of product and on basis of weight the price will get update. at front end. Means initially i set 10gram weight. and when user enter 20 gram or 25 gram whatever, the price need to update as per weight. – Ashwini Sep 22 '15 at 06:00
  • For this you need to do like explained here: http://stackoverflow.com/questions/20801596/how-to-implement-dynamic-calculating-price-in-magento-based-on-weight – Pankaj Pareek Sep 22 '15 at 06:43