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(
'general/locale/weight_unit',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
and call in your template echo $this->getWeightUnit();
If you have the product loaded inside your custom phtml file, you can use:
$weight = $product->getData('weight');