Mage_Core_Model_Locale
extends DataObject
in package
Table of Contents
Constants
- DATE_FORMAT : mixed = 'Y-m-d'
- DATETIME_FORMAT : mixed = 'Y-m-d H:i:s'
- Date format constants
- DEFAULT_CURRENCY : mixed = 'USD'
- DEFAULT_LOCALE : mixed = 'en_US'
- Default locale name
- DEFAULT_TIMEZONE : mixed = 'UTC'
- FORMAT_TYPE_FULL : mixed = 'full'
- Date and time format codes
- FORMAT_TYPE_LONG : mixed = 'long'
- FORMAT_TYPE_MEDIUM : mixed = 'medium'
- FORMAT_TYPE_SHORT : mixed = 'short'
- HTML5_DATETIME_FORMAT : mixed = 'Y-m-d\TH:i'
- LENGTH_CENTIMETER : mixed = 'cm'
- LENGTH_FOOT : mixed = 'ft'
- LENGTH_INCH : mixed = 'in'
- LENGTH_KILOMETER : mixed = 'km'
- LENGTH_METER : mixed = 'm'
- Length unit constants
- LENGTH_MILE : mixed = 'mi'
- LENGTH_MILLIMETER : mixed = 'mm'
- LENGTH_YARD : mixed = 'yd'
- WEIGHT_GRAM : mixed = 'g'
- WEIGHT_KILOGRAM : mixed = 'kg'
- Weight unit constants
- WEIGHT_OUNCE : mixed = 'oz'
- WEIGHT_POUND : mixed = 'lb'
- WEIGHT_TON : mixed = 't'
- XML_PATH_ALLOW_CODES : mixed = 'global/locale/allow/codes'
- XML_PATH_ALLOW_CURRENCIES : mixed = 'global/locale/allow/currencies'
- XML_PATH_ALLOW_CURRENCIES_INSTALLED : mixed = 'system/currency/installed'
- XML_PATH_DEFAULT_LOCALE : mixed = 'general/locale/code'
- XML path constants
- XML_PATH_DEFAULT_TIMEZONE : mixed = 'general/locale/timezone'
Properties
- $_currencyCache : mixed
- $_data : array<string|int, mixed>|null
- Object attributes
- $_defaultLocale : string
- Default locale code
- $_dirty : array<string|int, mixed>
- $_emulatedLocales : array<string|int, mixed>
- Emulated locales stack
- $_hasDataChanges : bool
- Data changes flag (true after setData|unsetData call)
- $_idFieldName : string
- Name of object id field
- $_isDeleted : bool
- Object delete flag
- $_localeCode : string
- Locale code
- $_numberFormatterCache : array<string|int, NumberFormatter>
- $_oldFieldsMap : array<string|int, mixed>
- Map short fields names to its full names
- $_syncFieldsMap : mixed
- Map of fields to sync to other fields upon changing their data
- $_underscoreCache : array<string|int, mixed>
- Setter/Getter underscore transformation cache
Methods
- __call() : mixed
- Set/Get attribute wrapper
- __construct() : mixed
- Constructor
- __get() : mixed
- Attribute getter (deprecated)
- __set() : mixed
- Attribute setter (deprecated)
- __toArray() : array<string|int, mixed>
- Convert object attributes to array
- addData() : $this
- Add data to the object.
- currency() : NumberFormatter
- Create NumberFormatter object for current locale configured for currency
- date() : DateTime
- dateImmutable() : DateTimeImmutable
- Create immutable DateTime object for current locale
- dateMutable() : DateTime
- Create mutable DateTime object for current locale Alias for date() method with explicit name
- debug() : string|array<string|int, mixed>
- Present object data as string in debug mode
- emulate() : void
- Push current locale to stack and replace with locale from specified store Event is not dispatched.
- flagDirty() : $this
- formatCurrency() : string
- Format currency value using locale-specific formatting
- formatDateForDb() : string|null
- Format any date input to database format string.
- formatPrice() : string
- Format price value using store's base currency
- getAllowCurrencies() : array<string|int, mixed>
- Retrieve array of allowed currencies
- getAllowLocales() : array<string|int, mixed>
- Retrieve array of allowed locales
- getCountryTranslation() : false|string
- Returns the localized country name
- getCountryTranslationList() : array<string, string>
- Returns an array with the name of all countries translated to the given language
- getCurrency() : string
- Retrieve currency code
- getCurrencySymbol() : string
- Get currency symbol for a given currency code
- getData() : mixed
- Object data getter
- getDataByKey() : mixed
- Get object data by particular key
- getDataByPath() : mixed
- Get object data by path
- getDataSetDefault() : mixed
- Fast get data or set default if value is not available
- getDataUsingMethod() : mixed
- Get object data by key with calling getter method
- getDateFormat() : string
- Retrieve date format pattern for display purposes (ICU pattern) Use this for frontend forms, user interfaces, display formatting
- getDateFormatByPeriodType() : string
- Retrieve date format by period type
- getDateFormatWithLongYear() : string
- Retrieve short date format with 4-digit year
- getDateTimeFormat() : string
- Retrieve ISO datetime format
- getDefaultLocale() : string
- REtrieve default locale code
- getId() : mixed
- Retrieve object id
- getIdFieldName() : string
- Retrieve name of object id field
- getJsPriceFormat() : array<string|int, mixed>
- Functions returns array with price formatting info for js function formatCurrency in js/varien/js.js
- getLocale() : string
- Retrieve locale object (compatibility method - returns locale code instead)
- getLocaleCode() : string
- Retrieve locale code
- getNumber() : float|null
- Returns the first found number from an string Parsing depends on given locale (grouping and decimal)
- getOptionAllCurrencies() : array<string|int, mixed>
- Retrieve all currency option list
- getOptionCountries() : array<string|int, mixed>
- Retrieve country option list
- getOptionCurrencies() : array<string|int, mixed>
- Retrieve currency option list
- getOptionLocales() : array<string|int, mixed>
- Get options array for locale dropdown in current locale
- getOptionTimezones() : array<string|int, mixed>
- Retrieve timezone option list
- getOptionWeekdays() : array<string|int, mixed>
- Retrieve days of week option list
- getTimeFormat() : string
- Retrieve time format pattern for display purposes (ICU pattern) Use this for frontend forms, user interfaces, display formatting
- getTimezone() : string
- Retrieve timezone code
- getTranslatedOptionLocales() : array<string|int, mixed>
- Get translated to original locale options array for locale dropdown
- getTranslation() : string|false
- Returns a localized information string, supported are several types of information.
- getTranslationList() : array<string|int, mixed>
- Returns localized information as array, supported are several types of information.
- hasData() : bool
- If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.
- hasDataChanges() : bool
- Get data change status
- isDeleted() : bool
- Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value
- isDirty() : bool
- isEmpty() : bool
- checks whether the object is empty
- isStoreDateInInterval() : bool
- Checks if current date of the given store (in the store timezone) is within the range
- isValidDate() : bool
- Validate date string with auto-detection of HTML5/ISO format
- jsonSerialize() : array<string|int, mixed>
- Implementation of JsonSerializable::jsonSerialize()
- normalizeNumber() : float|false
- Normalize a locale-formatted number string to float
- nowUtc() : string
- Current UTC datetime as a 'Y-m-d H:i:s' string, suitable for DB columns.
- offsetExists() : bool
- Implementation of ArrayAccess::offsetExists()
- offsetGet() : mixed
- Implementation of ArrayAccess::offsetGet()
- offsetSet() : void
- Implementation of ArrayAccess::offsetSet()
- offsetUnset() : void
- Implementation of ArrayAccess::offsetUnset()
- revert() : void
- Get last locale, used before last emulation
- serialize() : string
- serialize object attributes
- setData() : $this
- Overwrite data in the object.
- setDataChanges() : $this
- Clears data changes status
- setDataUsingMethod() : $this
- Set object data with calling setter method
- setDefaultLocale() : self
- Set default locale code
- setId() : $this
- Set object id field value
- setIdFieldName() : $this
- set name of object id field
- setLocale() : self
- Set locale
- setLocaleCode() : self
- Specify current locale code
- storeDate() : DateTime|string|null
- Create DateTime object with date converted to store timezone and store Locale
- storeTimeStamp() : int
- Get store timestamp
- storeToUtc() : DateTimeImmutable
- Convert a store-timezone date to UTC.
- toArray() : array<string|int, mixed>
- Public wrapper for __toArray
- todayUtc() : string
- Current UTC date (no time) as a 'Y-m-d' string, suitable for date-only DB columns.
- toJson() : string
- Public wrapper for __toJson
- toString() : string
- Public wrapper for __toString
- toXml() : string
- Public wrapper for __toXml
- unsetData() : $this
- Unset data from the object.
- unsetOldData() : $this
- Unset old fields data from the object.
- utcDate() : DateTime|string|null
- Create DateTime object with date converted from store's timezone to UTC time zone. Date can be passed in format of store's locale or in format which was passed as parameter.
- utcToStore() : DateTimeImmutable
- Convert a UTC date to the store's configured timezone.
- __toJson() : string
- Convert object attributes to JSON
- __toXml() : string
- Convert object attributes to XML
- _addFullNames() : mixed
- _camelize() : string
- _construct() : void
- Internal constructor not depended on params. Can be used for object initialization
- _convertYearTwoDigitTo4() : string
- Replace all yy date format to yyyy
- _getCurrencyList() : array<string|int, mixed>
- Get currency list
- _getData() : mixed
- Get value from _data array without parse key
- _getOptionLocales() : array<string|int, mixed>
- Get options array for locale dropdown
- _initOldFieldsMap() : mixed
- Inits mapping array of object's previously used fields to new fields.
- _prepareArray() : array<string|int, mixed>
- Set required array elements
- _prepareSyncFieldsMap() : $this
- Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.
- _sortOptionArray() : array<string|int, mixed>
- _underscore() : string
- Converts field names for setters and getters
- getNativeCountryList() : array<string, string>
- Get native country list using PHP Intl extension (dynamically from ICU data)
- getNativeCountryName() : string
- Get native country name using PHP Intl extension
- parseDate() : DateTimeImmutable
- Parse various date input types into a DateTimeImmutable in the given timezone.
Constants
DATE_FORMAT
public
mixed
DATE_FORMAT
= 'Y-m-d'
DATETIME_FORMAT
Date format constants
public
mixed
DATETIME_FORMAT
= 'Y-m-d H:i:s'
DEFAULT_CURRENCY
public
mixed
DEFAULT_CURRENCY
= 'USD'
DEFAULT_LOCALE
Default locale name
public
mixed
DEFAULT_LOCALE
= 'en_US'
DEFAULT_TIMEZONE
public
mixed
DEFAULT_TIMEZONE
= 'UTC'
FORMAT_TYPE_FULL
Date and time format codes
public
mixed
FORMAT_TYPE_FULL
= 'full'
FORMAT_TYPE_LONG
public
mixed
FORMAT_TYPE_LONG
= 'long'
FORMAT_TYPE_MEDIUM
public
mixed
FORMAT_TYPE_MEDIUM
= 'medium'
FORMAT_TYPE_SHORT
public
mixed
FORMAT_TYPE_SHORT
= 'short'
HTML5_DATETIME_FORMAT
public
mixed
HTML5_DATETIME_FORMAT
= 'Y-m-d\TH:i'
LENGTH_CENTIMETER
public
mixed
LENGTH_CENTIMETER
= 'cm'
LENGTH_FOOT
public
mixed
LENGTH_FOOT
= 'ft'
LENGTH_INCH
public
mixed
LENGTH_INCH
= 'in'
LENGTH_KILOMETER
public
mixed
LENGTH_KILOMETER
= 'km'
LENGTH_METER
Length unit constants
public
mixed
LENGTH_METER
= 'm'
LENGTH_MILE
public
mixed
LENGTH_MILE
= 'mi'
LENGTH_MILLIMETER
public
mixed
LENGTH_MILLIMETER
= 'mm'
LENGTH_YARD
public
mixed
LENGTH_YARD
= 'yd'
WEIGHT_GRAM
public
mixed
WEIGHT_GRAM
= 'g'
WEIGHT_KILOGRAM
Weight unit constants
public
mixed
WEIGHT_KILOGRAM
= 'kg'
WEIGHT_OUNCE
public
mixed
WEIGHT_OUNCE
= 'oz'
WEIGHT_POUND
public
mixed
WEIGHT_POUND
= 'lb'
WEIGHT_TON
public
mixed
WEIGHT_TON
= 't'
XML_PATH_ALLOW_CODES
public
mixed
XML_PATH_ALLOW_CODES
= 'global/locale/allow/codes'
XML_PATH_ALLOW_CURRENCIES
public
mixed
XML_PATH_ALLOW_CURRENCIES
= 'global/locale/allow/currencies'
XML_PATH_ALLOW_CURRENCIES_INSTALLED
public
mixed
XML_PATH_ALLOW_CURRENCIES_INSTALLED
= 'system/currency/installed'
XML_PATH_DEFAULT_LOCALE
XML path constants
public
mixed
XML_PATH_DEFAULT_LOCALE
= 'general/locale/code'
XML_PATH_DEFAULT_TIMEZONE
public
mixed
XML_PATH_DEFAULT_TIMEZONE
= 'general/locale/timezone'
Properties
$_currencyCache
protected
static mixed
$_currencyCache
= []
$_data
Object attributes
protected
array<string|int, mixed>|null
$_data
= []
$_defaultLocale
Default locale code
protected
string
$_defaultLocale
$_dirty
protected
array<string|int, mixed>
$_dirty
$_emulatedLocales
Emulated locales stack
protected
array<string|int, mixed>
$_emulatedLocales
= []
$_hasDataChanges
Data changes flag (true after setData|unsetData call)
protected
bool
$_hasDataChanges
= false
$_idFieldName
Name of object id field
protected
string
$_idFieldName
= null
$_isDeleted
Object delete flag
protected
bool
$_isDeleted
= false
$_localeCode
Locale code
protected
string
$_localeCode
$_numberFormatterCache
protected
static array<string|int, NumberFormatter>
$_numberFormatterCache
= []
$_oldFieldsMap
Map short fields names to its full names
protected
array<string|int, mixed>
$_oldFieldsMap
= []
$_syncFieldsMap
Map of fields to sync to other fields upon changing their data
protected
mixed
$_syncFieldsMap
= []
$_underscoreCache
Setter/Getter underscore transformation cache
protected
static array<string|int, mixed>
$_underscoreCache
= []
Methods
__call()
Set/Get attribute wrapper
public
__call(string $method, array<string|int, mixed> $args) : mixed
Parameters
- $method : string
- $args : array<string|int, mixed>
__construct()
Constructor
public
__construct() : mixed
By default, is looking for first argument as array and assigns it as object attributes This behaviour may change in child classes
__get()
Attribute getter (deprecated)
public
__get(string $var) : mixed
Parameters
- $var : string
__set()
Attribute setter (deprecated)
public
__set(string $var, mixed $value) : mixed
Parameters
- $var : string
- $value : mixed
__toArray()
Convert object attributes to array
public
__toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
- $arrAttributes : array<string|int, mixed> = []
-
array of required attributes
Return values
array<string|int, mixed>addData()
Add data to the object.
public
addData(array<string|int, mixed> $arr) : $this
Retains previous data in the object.
Parameters
- $arr : array<string|int, mixed>
Return values
$thiscurrency()
Create NumberFormatter object for current locale configured for currency
public
currency(string $currency) : NumberFormatter
Parameters
- $currency : string
Return values
NumberFormatterdate()
public
date([string|int|DateTime|DateTimeImmutable|null $date = null ][, string $part = null ][, string|null $locale = null ][, bool $useTimezone = true ]) : DateTime
since 26.5 Use utcToStore() or storeToUtc() instead
Parameters
- $date : string|int|DateTime|DateTimeImmutable|null = null
- $part : string = null
- $locale : string|null = null
- $useTimezone : bool = true
Tags
Return values
DateTimedateImmutable()
Create immutable DateTime object for current locale
public
dateImmutable([string|int|DateTime|null $date = null ][, string|null $part = null ][, string|null $locale = null ][, bool $useTimezone = true ]) : DateTimeImmutable
since 26.5 Use utcToStore() or storeToUtc() with DateTimeImmutable::createFromMutable() instead
Parameters
- $date : string|int|DateTime|null = null
- $part : string|null = null
- $locale : string|null = null
- $useTimezone : bool = true
Tags
Return values
DateTimeImmutabledateMutable()
Create mutable DateTime object for current locale Alias for date() method with explicit name
public
dateMutable([string|int|DateTime|null $date = null ][, string|null $part = null ][, string|null $locale = null ][, bool $useTimezone = true ]) : DateTime
since 26.5 Use utcToStore() or storeToUtc() instead
Parameters
- $date : string|int|DateTime|null = null
- $part : string|null = null
- $locale : string|null = null
- $useTimezone : bool = true
Tags
Return values
DateTimedebug()
Present object data as string in debug mode
public
debug([mixed $data = null ][, array<string|int, mixed> &$objects = [] ]) : string|array<string|int, mixed>
Parameters
- $data : mixed = null
- $objects : array<string|int, mixed> = []
Return values
string|array<string|int, mixed>emulate()
Push current locale to stack and replace with locale from specified store Event is not dispatched.
public
emulate(mixed $store) : void
Parameters
- $store : mixed
flagDirty()
public
flagDirty(string $field[, bool $flag = true ]) : $this
Parameters
- $field : string
- $flag : bool = true
Return values
$thisformatCurrency()
Format currency value using locale-specific formatting
public
formatCurrency(float|int|string|null $value, string $currencyCode) : string
Parameters
- $value : float|int|string|null
- $currencyCode : string
Return values
stringformatDateForDb()
Format any date input to database format string.
public
formatDateForDb(int|string|DateTime|DateTimeImmutable|null $date[, bool $withTime = true ]) : string|null
Does not perform timezone conversion. DateTime/DateTimeImmutable inputs are formatted in their current timezone; string inputs are parsed as UTC; int inputs are formatted as UTC via gmdate(). Callers should ensure the input is already in the desired timezone (typically UTC for strings/ints, or the correct timezone for DateTime objects).
Parameters
- $date : int|string|DateTime|DateTimeImmutable|null
-
Date input
- $withTime : bool = true
-
Whether to include time component
Return values
string|null —Formatted date string or null if input is empty
formatPrice()
Format price value using store's base currency
public
formatPrice(float|int|string|null $value[, int|string|null $storeId = null ]) : string
Parameters
- $value : float|int|string|null
- $storeId : int|string|null = null
Return values
stringgetAllowCurrencies()
Retrieve array of allowed currencies
public
getAllowCurrencies() : array<string|int, mixed>
Return values
array<string|int, mixed>getAllowLocales()
Retrieve array of allowed locales
public
getAllowLocales() : array<string|int, mixed>
Return values
array<string|int, mixed>getCountryTranslation()
Returns the localized country name
public
getCountryTranslation(string $countryId[, string $locale = null ]) : false|string
Parameters
- $countryId : string
-
Country to get detailed information about
- $locale : string = null
-
Locale to get translation for, or system locale if null
Return values
false|stringgetCountryTranslationList()
Returns an array with the name of all countries translated to the given language
public
getCountryTranslationList() : array<string, string>
Return values
array<string, string>getCurrency()
Retrieve currency code
public
getCurrency() : string
Return values
stringgetCurrencySymbol()
Get currency symbol for a given currency code
public
getCurrencySymbol(string $currencyCode) : string
Parameters
- $currencyCode : string
Return values
stringgetData()
Object data getter
public
getData([string $key = '' ][, string|int $index = null ]) : mixed
If $key is not defined will return all the data as an array. Otherwise, it will return value of the element specified by $key. It is possible to use keys like a/b/c for access nested array data
If $index is specified it will assume that attribute data is an array and retrieve corresponding member. If data is the string - it will be explode by new line character and converted to array.
Parameters
- $key : string = ''
- $index : string|int = null
getDataByKey()
Get object data by particular key
public
getDataByKey(string $key) : mixed
Parameters
- $key : string
getDataByPath()
Get object data by path
public
getDataByPath(string $path) : mixed
Method consider the path as chain of keys: a/b/c => ['a']['b']['c']
Parameters
- $path : string
getDataSetDefault()
Fast get data or set default if value is not available
public
getDataSetDefault(string $key, mixed $default) : mixed
Parameters
- $key : string
- $default : mixed
getDataUsingMethod()
Get object data by key with calling getter method
public
getDataUsingMethod(string $key[, mixed $args = null ]) : mixed
Parameters
- $key : string
- $args : mixed = null
getDateFormat()
Retrieve date format pattern for display purposes (ICU pattern) Use this for frontend forms, user interfaces, display formatting
public
getDateFormat([string|null $type = null ]) : string
Parameters
- $type : string|null = null
Return values
stringgetDateFormatByPeriodType()
Retrieve date format by period type
public
getDateFormatByPeriodType([string|null $period = null ]) : string
Parameters
- $period : string|null = null
-
Valid values: ["day", "month", "year"]
Return values
stringgetDateFormatWithLongYear()
Retrieve short date format with 4-digit year
public
getDateFormatWithLongYear() : string
Return values
stringgetDateTimeFormat()
Retrieve ISO datetime format
public
getDateTimeFormat(string $type) : string
Parameters
- $type : string
Return values
stringgetDefaultLocale()
REtrieve default locale code
public
getDefaultLocale() : string
Return values
stringgetId()
Retrieve object id
public
getId() : mixed
getIdFieldName()
Retrieve name of object id field
public
getIdFieldName() : string
Return values
stringgetJsPriceFormat()
Functions returns array with price formatting info for js function formatCurrency in js/varien/js.js
public
getJsPriceFormat() : array<string|int, mixed>
Return values
array<string|int, mixed>getLocale()
Retrieve locale object (compatibility method - returns locale code instead)
public
getLocale() : string
Return values
stringgetLocaleCode()
Retrieve locale code
public
getLocaleCode() : string
Return values
stringgetNumber()
Returns the first found number from an string Parsing depends on given locale (grouping and decimal)
public
getNumber(string|float|int $value) : float|null
Examples for input: ' 2345.4356,1234' = 23455456.1234 '+23,3452.123' = 233452.123 ' 12343 ' = 12343 '-9456km' = -9456 '0' = 0 '2 054,10' = 2054.1 '2'054.52' = 2054.52 '2,46 GB' = 2.46
Parameters
- $value : string|float|int
Return values
float|nullgetOptionAllCurrencies()
Retrieve all currency option list
public
getOptionAllCurrencies() : array<string|int, mixed>
Return values
array<string|int, mixed>getOptionCountries()
Retrieve country option list
public
getOptionCountries() : array<string|int, mixed>
Return values
array<string|int, mixed>getOptionCurrencies()
Retrieve currency option list
public
getOptionCurrencies() : array<string|int, mixed>
Return values
array<string|int, mixed>getOptionLocales()
Get options array for locale dropdown in current locale
public
getOptionLocales() : array<string|int, mixed>
Return values
array<string|int, mixed>getOptionTimezones()
Retrieve timezone option list
public
getOptionTimezones() : array<string|int, mixed>
Return values
array<string|int, mixed>getOptionWeekdays()
Retrieve days of week option list
public
getOptionWeekdays([bool $preserveCodes = false ][, bool $ucFirstCode = false ]) : array<string|int, mixed>
Parameters
- $preserveCodes : bool = false
- $ucFirstCode : bool = false
Return values
array<string|int, mixed>getTimeFormat()
Retrieve time format pattern for display purposes (ICU pattern) Use this for frontend forms, user interfaces, display formatting
public
getTimeFormat([string $type = null ]) : string
Parameters
- $type : string = null
Return values
stringgetTimezone()
Retrieve timezone code
public
getTimezone() : string
Return values
stringgetTranslatedOptionLocales()
Get translated to original locale options array for locale dropdown
public
getTranslatedOptionLocales() : array<string|int, mixed>
Return values
array<string|int, mixed>getTranslation()
Returns a localized information string, supported are several types of information.
public
getTranslation([string $value = null ][, string $path = null ][, string|null $locale = null ]) : string|false
For detailed information about the types look into the documentation
Parameters
- $value : string = null
-
Name to get detailed information about
- $path : string = null
-
(Optional) Type of information to return
- $locale : string|null = null
Return values
string|false —The wished information in the given language
getTranslationList()
Returns localized information as array, supported are several types of information.
public
getTranslationList([string $path = null ][, string $value = null ]) : array<string|int, mixed>
For detailed information about the types look into the documentation
Parameters
- $path : string = null
-
(Optional) Type of information to return
- $value : string = null
-
(Optional) Value for detail list
Return values
array<string|int, mixed> —Array with the wished information in the given language
hasData()
If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.
public
hasData([string $key = '' ]) : bool
Parameters
- $key : string = ''
Return values
boolhasDataChanges()
Get data change status
public
hasDataChanges() : bool
Return values
boolisDeleted()
Set _isDeleted flag value (if $isDeleted param is defined) and return current flag value
public
isDeleted([bool $isDeleted = null ]) : bool
Parameters
- $isDeleted : bool = null
Return values
boolisDirty()
public
isDirty([string $field = null ]) : bool
Parameters
- $field : string = null
Return values
boolisEmpty()
checks whether the object is empty
public
isEmpty() : bool
Return values
boolisStoreDateInInterval()
Checks if current date of the given store (in the store timezone) is within the range
public
isStoreDateInInterval(int|string|Mage_Core_Model_Store|null $store[, string|null $dateFrom = null ][, string|null $dateTo = null ]) : bool
Parameters
- $store : int|string|Mage_Core_Model_Store|null
- $dateFrom : string|null = null
- $dateTo : string|null = null
Return values
boolisValidDate()
Validate date string with auto-detection of HTML5/ISO format
public
static isValidDate(string $date) : bool
Parameters
- $date : string
-
The date string to validate
Return values
booljsonSerialize()
Implementation of JsonSerializable::jsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Prepares the object data for JSON serialization. Returns all object data as an array, with special handling for nested DataObject instances:
- If a nested DataObject has a custom jsonSerialize() implementation, it's preserved as-is
- If a nested DataObject has a custom toJson() method, it's converted to JSON string
- If a nested DataObject uses only the base implementations, it's excluded from output
This prevents infinite recursion and circular references when serializing object hierarchies.
Attributes
- #[Override]
Return values
array<string|int, mixed>normalizeNumber()
Normalize a locale-formatted number string to float
public
normalizeNumber(string $value) : float|false
Parameters
- $value : string
Return values
float|falsenowUtc()
Current UTC datetime as a 'Y-m-d H:i:s' string, suitable for DB columns.
public
static nowUtc() : string
The "Utc" suffix is intentional: the whole codebase stores timestamps in UTC, and the method name makes that invariant visible at every call site — no need to check the docblock to know which timezone the returned string is in. Uses gmdate() internally, so the result is UTC regardless of PHP's default timezone.
If you need "now" in the store's timezone (for computation or display), call $locale->utcToStore() with no arguments — it returns a DateTime you can format however you want. Do NOT format this method's return value as if it were store-local; it isn't.
No companion nowInStoreTimezone() / nowStore() method exists, and that's deliberate:
- A store-local datetime string in a DB column is ambiguous (same string, different instants across stores) and would violate the "DB is always UTC" invariant this API relies on.
- For computation or display you want a DateTime object, not a string, so you can do arithmetic or pass it to a locale-aware formatter — utcToStore() already returns that. A nowStore() string method would invite exactly the bug class the UTC-only DB convention is meant to prevent, so the API forces you to reach for utcToStore() instead.
Return values
stringoffsetExists()
Implementation of ArrayAccess::offsetExists()
public
offsetExists(string $offset) : bool
Parameters
- $offset : string
Tags
Attributes
- #[Override]
Return values
booloffsetGet()
Implementation of ArrayAccess::offsetGet()
public
offsetGet(string $offset) : mixed
Parameters
- $offset : string
Tags
Attributes
- #[Override]
- #[ReturnTypeWillChange]
offsetSet()
Implementation of ArrayAccess::offsetSet()
public
offsetSet(string $offset, mixed $value) : void
Parameters
- $offset : string
- $value : mixed
Tags
Attributes
- #[Override]
offsetUnset()
Implementation of ArrayAccess::offsetUnset()
public
offsetUnset(string $offset) : void
Parameters
- $offset : string
Tags
Attributes
- #[Override]
revert()
Get last locale, used before last emulation
public
revert() : void
serialize()
serialize object attributes
public
serialize([array<string|int, mixed> $attributes = [] ][, string $valueSeparator = '=' ][, string $fieldSeparator = ' ' ][, string $quote = '"' ]) : string
Parameters
- $attributes : array<string|int, mixed> = []
- $valueSeparator : string = '='
- $fieldSeparator : string = ' '
- $quote : string = '"'
Return values
stringsetData()
Overwrite data in the object.
public
setData(string|array<string|int, mixed> $key[, mixed $value = null ]) : $this
$key can be string or array. If $key is string, the attribute value will be overwritten by $value
If $key is an array, it will overwrite all the data in the object.
Parameters
- $key : string|array<string|int, mixed>
- $value : mixed = null
Return values
$thissetDataChanges()
Clears data changes status
public
setDataChanges(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetDataUsingMethod()
Set object data with calling setter method
public
setDataUsingMethod(string $key[, mixed $args = [] ]) : $this
Parameters
- $key : string
- $args : mixed = []
Return values
$thissetDefaultLocale()
Set default locale code
public
setDefaultLocale(string $locale) : self
Parameters
- $locale : string
Return values
selfsetId()
Set object id field value
public
setId(mixed $value) : $this
Parameters
- $value : mixed
Return values
$thissetIdFieldName()
set name of object id field
public
setIdFieldName(string $name) : $this
Parameters
- $name : string
Return values
$thissetLocale()
Set locale
public
setLocale([string $locale = null ]) : self
Parameters
- $locale : string = null
Return values
selfsetLocaleCode()
Specify current locale code
public
setLocaleCode(string $code) : self
Parameters
- $code : string
Return values
selfstoreDate()
Create DateTime object with date converted to store timezone and store Locale
public
storeDate([null|string|bool|int|Mage_Core_Model_Store $store = null ][, string|int|DateTime|DateTimeImmutable|null $date = null ][, bool $includeTime = false ][, string|null $format = null ]) : DateTime|string|null
since 26.5 Use utcToStore() instead. Callers should format the result themselves.
Parameters
- $store : null|string|bool|int|Mage_Core_Model_Store = null
-
Information about store
- $date : string|int|DateTime|DateTimeImmutable|null = null
-
date in UTC
- $includeTime : bool = false
-
flag for including time to date
- $format : string|null = null
-
Format for date parsing/output:
- null: Use locale default format (returns DateTime)
- 'html5': Return HTML5 native input format (returns string):
- type="date": YYYY-MM-DD (e.g., "2024-12-25")
- type="datetime-local": YYYY-MM-DDTHH:mm (e.g., "2024-12-25T14:30")
- PHP format strings: 'Y-m-d H:i:s', etc. (returns DateTime)
Tags
Return values
DateTime|string|nullstoreTimeStamp()
Get store timestamp
public
storeTimeStamp([mixed $store = null ]) : int
since 26.5 Use utcToStore($store) for store-local dates, or time() for real timestamps
Timestamp will be built with store timezone settings
Parameters
- $store : mixed = null
Tags
Return values
intstoreToUtc()
Convert a store-timezone date to UTC.
public
storeToUtc([null|string|bool|int|Mage_Core_Model_Store $store = null ][, string|int|DateTime|DateTimeImmutable|null $date = null ]) : DateTimeImmutable
Always returns a DateTimeImmutable object with UTC timezone set. Use PHP's DateTimeImmutable::format() for machine-readable output (e.g. $result->format('Y-m-d H:i:s')). For locale-aware display formatting, use Mage::helper('core')->formatDate() instead.
Note: if $date is a DateTime/DateTimeImmutable, its existing timezone is preserved as the source timezone (i.e. setTimezone converts from the object's current TZ, not necessarily the store's timezone). For correct results, pass DateTime objects that are already in store TZ.
Parameters
- $store : null|string|bool|int|Mage_Core_Model_Store = null
-
Store (null = current store)
- $date : string|int|DateTime|DateTimeImmutable|null = null
-
Date in store timezone (null or 'now' = current time)
Return values
DateTimeImmutabletoArray()
Public wrapper for __toArray
public
toArray([array<string|int, mixed> $arrAttributes = [] ]) : array<string|int, mixed>
Parameters
- $arrAttributes : array<string|int, mixed> = []
Return values
array<string|int, mixed>todayUtc()
Current UTC date (no time) as a 'Y-m-d' string, suitable for date-only DB columns.
public
static todayUtc() : string
Same rationale as nowUtc() — the "Utc" suffix encodes the timezone at the call site, and the deliberate absence of a todayInStoreTimezone() / todayStore() counterpart prevents store-local date strings from creeping into DB columns. For "today" in the store's timezone, use $locale->utcToStore()->format('Y-m-d').
Return values
stringtoJson()
Public wrapper for __toJson
public
toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
Return values
stringtoString()
Public wrapper for __toString
public
toString([string $format = '' ]) : string
Will use $format as an template and substitute {{key}} for attributes
Parameters
- $format : string = ''
Return values
stringtoXml()
Public wrapper for __toXml
public
toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
- $rootName : string = 'item'
- $addOpenTag : bool = false
- $addCdata : bool = true
Return values
stringunsetData()
Unset data from the object.
public
unsetData([string $key = null ]) : $this
$key can be a string only. Array will be ignored.
Parameters
- $key : string = null
Return values
$thisunsetOldData()
Unset old fields data from the object.
public
unsetOldData([string $key = null ]) : $this
$key can be a string only. Array will be ignored.
Parameters
- $key : string = null
Return values
$thisutcDate()
Create DateTime object with date converted from store's timezone to UTC time zone. Date can be passed in format of store's locale or in format which was passed as parameter.
public
utcDate(mixed $store[, string|int|DateTime|DateTimeImmutable|null $date = null ][, bool $includeTime = false ][, null|string $format = null ]) : DateTime|string|null
since 26.5 Use storeToUtc() instead. Callers should format the result themselves.
Parameters
- $store : mixed
-
Information about store
- $date : string|int|DateTime|DateTimeImmutable|null = null
-
date in store's timezone
- $includeTime : bool = false
-
flag for including time to date
- $format : null|string = null
-
Format for date parsing/output:
- null: Use locale default format (returns DateTime)
- 'html5': Parse HTML5 native input format (returns string):
- Accepts: YYYY-MM-DD (from type="date") or YYYY-MM-DDTHH:mm (from type="datetime-local")
- Returns: YYYY-MM-DD HH:mm:ss (MySQL datetime format)
- PHP format strings: 'Y-m-d H:i:s', etc. (returns DateTime)
Tags
Return values
DateTime|string|nullutcToStore()
Convert a UTC date to the store's configured timezone.
public
utcToStore([null|string|bool|int|Mage_Core_Model_Store $store = null ][, string|int|DateTime|DateTimeImmutable|null $date = null ]) : DateTimeImmutable
Always returns a DateTimeImmutable object with the store's timezone set. Use PHP's DateTimeImmutable::format() for machine-readable output (e.g. $result->format('Y-m-d')). For locale-aware display formatting, use Mage::helper('core')->formatDate() instead.
Note: if $date is a DateTime/DateTimeImmutable, its existing timezone is preserved as the source timezone (i.e. setTimezone converts from the object's current TZ, not necessarily UTC). For correct results, pass DateTime objects that are already in UTC.
Parameters
- $store : null|string|bool|int|Mage_Core_Model_Store = null
-
Store (null = current store)
- $date : string|int|DateTime|DateTimeImmutable|null = null
-
Date in UTC (null or 'now' = current time)
Return values
DateTimeImmutable__toJson()
Convert object attributes to JSON
protected
__toJson([array<string|int, mixed> $arrAttributes = [] ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
-
array of required attributes
Return values
string__toXml()
Convert object attributes to XML
protected
__toXml([array<string|int, mixed> $arrAttributes = [] ][, string $rootName = 'item' ][, bool $addOpenTag = false ][, bool $addCdata = true ]) : string
Parameters
- $arrAttributes : array<string|int, mixed> = []
-
array of required attributes
- $rootName : string = 'item'
-
name of the root element
- $addOpenTag : bool = false
- $addCdata : bool = true
Return values
string_addFullNames()
protected
_addFullNames() : mixed
_camelize()
protected
_camelize(string $name) : string
Parameters
- $name : string
Return values
string_construct()
Internal constructor not depended on params. Can be used for object initialization
protected
_construct() : void
_convertYearTwoDigitTo4()
Replace all yy date format to yyyy
protected
_convertYearTwoDigitTo4(string $currentFormat) : string
Parameters
- $currentFormat : string
Return values
string_getCurrencyList()
Get currency list
protected
_getCurrencyList() : array<string|int, mixed>
Return values
array<string|int, mixed>_getData()
Get value from _data array without parse key
protected
_getData(string $key) : mixed
Parameters
- $key : string
_getOptionLocales()
Get options array for locale dropdown
protected
_getOptionLocales([bool $translatedName = false ]) : array<string|int, mixed>
Parameters
- $translatedName : bool = false
-
translation flag
Return values
array<string|int, mixed>_initOldFieldsMap()
Inits mapping array of object's previously used fields to new fields.
protected
_initOldFieldsMap() : mixed
Must be overloaded by descendants to set concrete fields map.
_prepareArray()
Set required array elements
protected
_prepareArray(array<string|int, mixed> &$arr[, array<string|int, mixed> $elements = [] ]) : array<string|int, mixed>
Parameters
- $arr : array<string|int, mixed>
- $elements : array<string|int, mixed> = []
Return values
array<string|int, mixed>_prepareSyncFieldsMap()
Called after old fields are inited. Forms synchronization map to sync old fields and new fields between each other.
protected
_prepareSyncFieldsMap() : $this
Return values
$this_sortOptionArray()
protected
_sortOptionArray(array<string|int, mixed> $option) : array<string|int, mixed>
Parameters
- $option : array<string|int, mixed>
Return values
array<string|int, mixed>_underscore()
Converts field names for setters and getters
protected
_underscore(string $name) : string
$this->setMyField($value) === $this->setData('my_field', $value) Uses cache to eliminate unnecessary preg_replace
Parameters
- $name : string
Return values
stringgetNativeCountryList()
Get native country list using PHP Intl extension (dynamically from ICU data)
protected
getNativeCountryList() : array<string, string>
Return values
array<string, string>getNativeCountryName()
Get native country name using PHP Intl extension
protected
getNativeCountryName(string $countryId[, string|null $locale = null ]) : string
Parameters
- $countryId : string
- $locale : string|null = null
Return values
stringparseDate()
Parse various date input types into a DateTimeImmutable in the given timezone.
private
parseDate(string|int|DateTime|DateTimeImmutable|null $date, DateTimeZone $timezone) : DateTimeImmutable
Parameters
- $date : string|int|DateTime|DateTimeImmutable|null
- $timezone : DateTimeZone