Pimcore\Model\Object\QuantityValue\Unit::getById PHP Method

getById() public static method

public static getById ( string $id ) : Unit
$id string
return Unit
    public static function getById($id)
    {
        $cacheKey = Unit\Dao::TABLE_NAME . "_" . $id;
        try {
            $unit = \Zend_Registry::get($cacheKey);
        } catch (\Exception $e) {
            try {
                $unit = new self();
                $unit->getDao()->getById($id);
                \Zend_Registry::set($cacheKey, $unit);
            } catch (\Exception $ex) {
                Logger::debug($ex->getMessage());
                return null;
            }
        }
        return $unit;
    }

Usage Example

 public function getUnit()
 {
     if (empty($this->unit)) {
         $this->unit = \Pimcore\Model\Object\QuantityValue\Unit::getById($this->unitId);
     }
     return $this->unit;
 }
All Usage Examples Of Pimcore\Model\Object\QuantityValue\Unit::getById