Magento – Get product weight unit in phtml file

configurationmagento2product-weight

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?

Best Answer

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(
        'general/locale/weight_unit',
        \Magento\Store\Model\ScopeInterface::SCOPE_STORE
    );
}

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

Related Topic