I have a phtml file that needs to load the weight unit of the product, the weight unit is from the store configuration, is there a way to do this?


For product weight unit. Try this -

You need to use the instance of \Magento\Framework\App\Config\ScopeConfigInterface in your block:

Create the method getWeightUnit()

public function getWeightUnit()
    return $this->_scopeConfig->getValue(

and call in your template echo $this->getWeightUnit();

  • .how to get the width unit in magento2 .... – Mahi M Mar 1 '19 at 10:39
  • Thanks! Tried this one and it worked! – MazeStricks Oct 25 '19 at 7:14

If you have the product loaded inside your custom phtml file, you can use:

$weight = $product->getData('weight');

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.