As I am new in Magento 2 development I am trying to add a weight unit Grams in weight drop down on product addition page on admin console but I can't get success. Can anyone please help me on this to add a new weight unit Grams?


Need to override \magento\vendor\magento\module-directory\Model\Config\Source\WeightUnit.php




<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Custom_Directory" setup_version="1.0.0">
            <module name="Magento_Directory"/>


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Directory\Model\Config\Source\WeightUnit" type="Custom\Directory\Model\Config\Source\WeightUnit" />


namespace Custom\Directory\Model\Config\Source;

class WeightUnit extends \Magento\Directory\Model\Config\Source\WeightUnit
     * {@inheritdoc}
    public function toOptionArray()
        return [['value' => 'lbs', 'label' => __('lbs')], ['value' => 'kgs', 'label' => __('kgs')], ['value' => 'gms', 'label' => __('grams')]];

Note: Be careful with your shipping methods. DHL, UPS, FedEx they allow only KG & LBS.

Reference for Magento 1 set weight units in grams

| improve this answer | |

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.