2

How to get the Unit of measure label of product attributes like weight,Length etc in product detail page?

enter image description here

2

This settings comes from system configuration.

Weight: Stores -> Configurations -> Generale -> Locale Options -> Weight Unit

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;

Then

/**
 * @var ScopeConfigInterface
 */
private $scopeConfig;

/**
 * @param ScopeConfigInterface $scopeConfig
 */
public function __construct(ScopeConfigInterface $scopeConfig)
{
    $this->scopeConfig = $scopeConfig;
}

Get value:

$weightUnit = $this->scopeConfig->getValue(
        'general/locale/weight_unit',
        ScopeInterface::SCOPE_STORE
    );

For dimension (width, length): here is the logic

vendor/temando/module-shipping-m2/Ui/DataProvider/Product/Form/Modifier/Dimensions.php

($weightUnit === 'kgs') ? 'cm' : 'in'
| improve this answer | |
  • How to get it from product detail page? – Mujahidh May 29 '19 at 9:37
  • Check updated answer – Sohel Rana May 29 '19 at 13:11

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.