'LA', 'California - San Francisco' => 'SF', 'Illinois' => 'IL', 'Maryland' => 'MD', 'New Jersey - Mount Laurel' => 'NJ', 'New York' => 'NY', 'Texas - Houston' => 'TX', 'Florida - Miami' => 'FL', 'Texas - Dallas' => 'DAL', 'Arizona' => 'AZ', 'Georgia' => 'GA', ); /** * @var \Magento\Eav\Api\AttributeRepositoryInterface */ protected $attributeRepository; /** * Data constructor. * @param \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository */ public function __construct( \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository ) { $this->attributeRepository = $attributeRepository; } /** * Gets the default store id * * @return int Returns the default store id */ public function getDefaultStoreId() { return \Magento\Store\Model\Store::DEFAULT_STORE_ID; } /** * Gets the customer attribute options * * @param string $attributeCode The attribute code * @return array Returns the customer attribute options */ public function getCustomerAttributeOptions($attributeCode) { try { $attribute = $this->attributeRepository->get('customer', $attributeCode); $options = $attribute->getOptions(); $result = []; foreach ($options as $option) { if ($option->getValue()) { $result[$option->getValue()] = $option->getLabel(); } } return $result; } catch (\Exception $e) { // Handle the exception appropriately return []; } } /** * Gets the office name by givin location name * * @param int @value The office value * @return string Returns the name of the office location */ public function getOfficeNameByValue($value) { $options = $this->getCustomerAttributeOptions('lts_office'); return isset($options[$value]) && isset(self::$offices[$options[$value]]) ? self::$offices[$options[$value]]:'UNKNOWN'; } }