Mage_Rule_Model_Resource_Rule
extends Mage_Rule_Model_Resource_Abstract
in package
Abstract Rule entity resource model
since 1.7.0.0 use Mage_Rule_Model_Resource_Abstract instead
Table of Contents
Constants
- CHECKSUM_KEY_NAME = 'Checksum'
Properties
- $_associatedEntitiesMap : array<string|int, mixed>
- Store associated with rule entities information map
- $_commitCallbacks : array<string|int, mixed>
- Array of callbacks subscribed to commit transaction commit
- $_connections : array<string|int, mixed>
- Connections cache for this resource model
- $_fieldsForUpdate : array<string|int, mixed>
- Fields List for update in forsedSave
- $_idFieldName : string
- Main table primary key field name
- $_isPkAutoIncrement : bool
- Primery key auto increment flag
- $_mainTable : string
- Main table name
- $_mainTableFields : array<string|int, mixed>
- Fields of main table
- $_resourceModel : string
- Resource model name that contains entities (names of tables)
- $_resourcePrefix : string
- Prefix for resources that will be used in this resource model
- $_resources : Mage_Core_Model_Resource
- Cached resources singleton
- $_serializableFields : array<string|int, mixed>
- Serializable fields declaration Structure: array( <field_name> => array( <default_value_for_serialization>, <default_for_unserialization>, <whether_to_unset_empty_when serializing> // optional parameter ), )
- $_tables : array<string|int, mixed>
- Tables used in this resource model
- $_uniqueFields : array<string|int, mixed>|null
- Main table unique keys field names could array( array('field' => 'db_field_name1', 'title' => 'Field 1 should be unique') array('field' => 'db_field_name2', 'title' => 'Field 2 should be unique') array( 'field' => array('db_field_name3', 'db_field_name3'), 'title' => 'Field 3 and Field 4 combination should be unique' ) ) or string 'my_field_name' - will be autoconverted to array( array( 'field' => 'my_field_name', 'title' => 'my_field_name' ) )
- $_useIsObjectNew : bool
- Use is object new method for save of object
Methods
- __construct() : mixed
- Main constructor
- _beforeSave() : Mage_Rule_Model_Resource_Abstract
- Prepare rule's active "from" and "to" dates
- addCommitCallback() : $this
- Subscribe some callback to transaction commit
- addUniqueField() : $this
- Add unique field restriction
- afterLoad() : mixed
- After load
- beginTransaction() : $this
- Start resource transaction
- bindRuleToEntity() : Mage_Rule_Model_Resource_Abstract
- Bind specified rules to entities
- commit() : $this
- Commit resource transaction
- delete() : $this
- Delete the object
- formatDate() : string|null
- Format date to internal format
- forsedSave() : $this
- Forced save object data forced update If duplicate unique key data
- getAssociatedEntityIds() : array<string|int, mixed>
- Retrieve rule's associated entity Ids by entity type
- getChecksum() : array<string|int, mixed>|false
- Retrieve table checksum
- getCustomerGroupIds() : array<string|int, mixed>
- Retrieve customer group ids of specified rule
- getIdFieldName() : string
- Get primary key field name
- getMainTable() : string
- Returns main table name - extracted from "module/table" style and validated by db adapter
- getProductFlatSelect() : Varien_Db_Select
- Prepare select for condition
- getReadConnection() : Varien_Db_Adapter_Interface
- Temporary resolving collection compatibility
- getTable() : string
- Get table name for the entity, validated by db adapter
- getUniqueFields() : array<string|int, mixed>
- Get configuration of all unique fields
- getValueTable() : string
- Retrieve table name for the entity separated value
- getWebsiteIds() : array<string|int, mixed>
- Retrieve website ids of specified rule
- hasConnection() : bool
- hasDataChanged() : bool
- Check that model data fields that can be saved has really changed comparing with origData
- isModuleEnabled() : bool
- load() : $this
- Load an object
- mktime() : int
- Convert internal date to UNIX timestamp
- resetUniqueField() : $this
- Reset unique fields restrictions
- rollBack() : $this
- Roll back resource transaction
- save() : $this
- Save object object data
- unbindRuleFromEntity() : Mage_Rule_Model_Resource_Abstract
- Unbind specified rules from entities
- unserializeFields() : mixed
- Un-serialize serializable object fields
- _afterDelete() : $this
- Perform actions after object delete
- _afterLoad() : $this
- Perform actions after object load
- _afterSave() : $this
- Perform actions after object save
- _beforeDelete() : $this
- Perform actions before object delete
- _checkUnique() : $this
- Check for unique values existence
- _construct() : mixed
- _getAssociatedEntityInfo() : array<string|int, mixed>
- Retrieve correspondent entity information (associations table name, columns names) of rule's associated entity by specified entity type
- _getConnection() : Varien_Db_Adapter_Pdo_Mysql
- Get connection by name or type
- _getLoadSelect() : Varien_Db_Select
- Retrieve select object for load object data
- _getReadAdapter() : Varien_Db_Adapter_Pdo_Mysql
- Retrieve connection for read data
- _getWriteAdapter() : Varien_Db_Adapter_Pdo_Mysql
- Retrieve connection for write data
- _init() : mixed
- Standard resource model initialization
- _initUniqueFields() : $this
- Initialize unique fields
- _prepareDataForSave() : array<string|int, mixed>
- Prepare data for save
- _prepareDataForTable() : array<string|int, mixed>
- Prepare data for passed table
- _prepareTableValueForSave() : mixed
- Prepare value for save
- _prepareValueForSave() : mixed
- Prepare value for save
- _serializeField() : $this
- Serialize specified field in an object
- _serializeFields() : mixed
- Serialize serializable fields of the object
- _setMainTable() : $this
- Set main entity table name and primary key field name If field name is omitted {table_name}_id will be used
- _setResource() : Mage_Core_Model_Resource_Abstract
- Initialize connections and tables for this resource model If one or both arguments are string, will be used as prefix If $tables is null and $connections is string, $tables will be the same
- _unserializeField() : mixed
- Unserialize Varien_Object field in an object
Constants
CHECKSUM_KEY_NAME
since 1.5.0.0
public
mixed
CHECKSUM_KEY_NAME
= 'Checksum'
Properties
$_associatedEntitiesMap
Store associated with rule entities information map
protected
array<string|int, mixed>
$_associatedEntitiesMap
= []
Example: array( 'entity_type1' => array( 'associations_table' => 'table_name', 'rule_id_field' => 'rule_id', 'entity_id_field' => 'entity_id' ), 'entity_type2' => array( 'associations_table' => 'table_name', 'rule_id_field' => 'rule_id', 'entity_id_field' => 'entity_id' ) .... )
$_commitCallbacks
Array of callbacks subscribed to commit transaction commit
protected
static array<string|int, mixed>
$_commitCallbacks
= []
$_connections
Connections cache for this resource model
protected
array<string|int, mixed>
$_connections
= []
$_fieldsForUpdate
Fields List for update in forsedSave
protected
array<string|int, mixed>
$_fieldsForUpdate
= []
$_idFieldName
Main table primary key field name
protected
string
$_idFieldName
$_isPkAutoIncrement
Primery key auto increment flag
protected
bool
$_isPkAutoIncrement
= \true
$_mainTable
Main table name
protected
string
$_mainTable
$_mainTableFields
Fields of main table
protected
array<string|int, mixed>
$_mainTableFields
$_resourceModel
Resource model name that contains entities (names of tables)
protected
string
$_resourceModel
$_resourcePrefix
Prefix for resources that will be used in this resource model
protected
string
$_resourcePrefix
$_resources
Cached resources singleton
protected
Mage_Core_Model_Resource
$_resources
$_serializableFields
Serializable fields declaration Structure: array( <field_name> => array( <default_value_for_serialization>, <default_for_unserialization>, <whether_to_unset_empty_when serializing> // optional parameter ), )
protected
array<string|int, mixed>
$_serializableFields
= []
$_tables
Tables used in this resource model
protected
array<string|int, mixed>
$_tables
= []
$_uniqueFields
Main table unique keys field names could array( array('field' => 'db_field_name1', 'title' => 'Field 1 should be unique') array('field' => 'db_field_name2', 'title' => 'Field 2 should be unique') array( 'field' => array('db_field_name3', 'db_field_name3'), 'title' => 'Field 3 and Field 4 combination should be unique' ) ) or string 'my_field_name' - will be autoconverted to array( array( 'field' => 'my_field_name', 'title' => 'my_field_name' ) )
protected
array<string|int, mixed>|null
$_uniqueFields
= \null
$_useIsObjectNew
Use is object new method for save of object
protected
bool
$_useIsObjectNew
= \false
Methods
__construct()
Main constructor
public
__construct() : mixed
_beforeSave()
Prepare rule's active "from" and "to" dates
public
_beforeSave(Mage_Core_Model_Abstract $object) : Mage_Rule_Model_Resource_Abstract
Parameters
- $object : Mage_Core_Model_Abstract
Attributes
- #[Override]
Return values
Mage_Rule_Model_Resource_AbstractaddCommitCallback()
Subscribe some callback to transaction commit
public
addCommitCallback(callable $callback) : $this
Parameters
- $callback : callable
Return values
$thisaddUniqueField()
Add unique field restriction
public
addUniqueField(array<string|int, mixed>|string $field) : $this
Parameters
- $field : array<string|int, mixed>|string
Return values
$thisafterLoad()
After load
public
afterLoad(Mage_Core_Model_Abstract $object) : mixed
Parameters
- $object : Mage_Core_Model_Abstract
beginTransaction()
Start resource transaction
public
beginTransaction() : $this
Return values
$thisbindRuleToEntity()
Bind specified rules to entities
public
bindRuleToEntity(array<string|int, mixed>|int|string $ruleIds, array<string|int, mixed>|int|string $entityIds, string $entityType[, bool $deleteOldResults = true ]) : Mage_Rule_Model_Resource_Abstract
Parameters
- $ruleIds : array<string|int, mixed>|int|string
- $entityIds : array<string|int, mixed>|int|string
- $entityType : string
- $deleteOldResults : bool = true
Tags
Return values
Mage_Rule_Model_Resource_Abstractcommit()
Commit resource transaction
public
commit() : $this
Return values
$thisdelete()
Delete the object
public
delete(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Tags
Return values
$thisformatDate()
Format date to internal format
public
formatDate(int|string|Zend_Date|bool|null $date[, bool $includeTime = true ]) : string|null
Parameters
- $date : int|string|Zend_Date|bool|null
- $includeTime : bool = true
Return values
string|nullforsedSave()
Forced save object data forced update If duplicate unique key data
public
forsedSave(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Return values
$thisgetAssociatedEntityIds()
Retrieve rule's associated entity Ids by entity type
public
getAssociatedEntityIds(int $ruleId, string $entityType) : array<string|int, mixed>
Parameters
- $ruleId : int
- $entityType : string
Return values
array<string|int, mixed>getChecksum()
Retrieve table checksum
public
getChecksum(string|array<string|int, mixed> $table) : array<string|int, mixed>|false
Parameters
- $table : string|array<string|int, mixed>
Return values
array<string|int, mixed>|falsegetCustomerGroupIds()
Retrieve customer group ids of specified rule
public
getCustomerGroupIds(int $ruleId) : array<string|int, mixed>
Parameters
- $ruleId : int
Return values
array<string|int, mixed>getIdFieldName()
Get primary key field name
public
getIdFieldName() : string
Return values
stringgetMainTable()
Returns main table name - extracted from "module/table" style and validated by db adapter
public
getMainTable() : string
Return values
stringgetProductFlatSelect()
Prepare select for condition
public
getProductFlatSelect(int $storeId, Mage_Rule_Model_Condition_Abstract $condition) : Varien_Db_Select
Parameters
- $storeId : int
- $condition : Mage_Rule_Model_Condition_Abstract
Return values
Varien_Db_SelectgetReadConnection()
Temporary resolving collection compatibility
public
getReadConnection() : Varien_Db_Adapter_Interface
Return values
Varien_Db_Adapter_InterfacegetTable()
Get table name for the entity, validated by db adapter
public
getTable(string|array<string|int, mixed> $entityName) : string
Parameters
- $entityName : string|array<string|int, mixed>
Return values
stringgetUniqueFields()
Get configuration of all unique fields
public
getUniqueFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getValueTable()
Retrieve table name for the entity separated value
public
getValueTable(string $entityName, string $valueType) : string
Parameters
- $entityName : string
- $valueType : string
Return values
stringgetWebsiteIds()
Retrieve website ids of specified rule
public
getWebsiteIds(int $ruleId) : array<string|int, mixed>
Parameters
- $ruleId : int
Return values
array<string|int, mixed>hasConnection()
public
hasConnection(string $connectionName) : bool
Parameters
- $connectionName : string
Return values
boolhasDataChanged()
Check that model data fields that can be saved has really changed comparing with origData
public
hasDataChanged(Mage_Core_Model_Abstract $object) : bool
Parameters
- $object : Mage_Core_Model_Abstract
Return values
boolisModuleEnabled()
public
isModuleEnabled(string $moduleName[, string $helperAlias = 'core' ]) : bool
Parameters
- $moduleName : string
- $helperAlias : string = 'core'
Return values
boolload()
Load an object
public
load(Mage_Core_Model_Abstract $object, mixed $value[, string|null $field = null ]) : $this
Parameters
- $object : Mage_Core_Model_Abstract
- $value : mixed
- $field : string|null = null
-
field to load by (defaults to model id)
Return values
$thismktime()
Convert internal date to UNIX timestamp
public
mktime(string $str) : int
Parameters
- $str : string
Return values
intresetUniqueField()
Reset unique fields restrictions
public
resetUniqueField() : $this
Return values
$thisrollBack()
Roll back resource transaction
public
rollBack() : $this
Return values
$thissave()
Save object object data
public
save(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Return values
$thisunbindRuleFromEntity()
Unbind specified rules from entities
public
unbindRuleFromEntity(array<string|int, mixed>|int|string $ruleIds, array<string|int, mixed>|int|string $entityIds, string $entityType) : Mage_Rule_Model_Resource_Abstract
Parameters
- $ruleIds : array<string|int, mixed>|int|string
- $entityIds : array<string|int, mixed>|int|string
- $entityType : string
Return values
Mage_Rule_Model_Resource_AbstractunserializeFields()
Un-serialize serializable object fields
public
unserializeFields(Mage_Core_Model_Abstract $object) : mixed
Parameters
- $object : Mage_Core_Model_Abstract
_afterDelete()
Perform actions after object delete
protected
_afterDelete(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Return values
$this_afterLoad()
Perform actions after object load
protected
_afterLoad(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Return values
$this_afterSave()
Perform actions after object save
protected
_afterSave(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Return values
$this_beforeDelete()
Perform actions before object delete
protected
_beforeDelete(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Return values
$this_checkUnique()
Check for unique values existence
protected
_checkUnique(Mage_Core_Model_Abstract $object) : $this
Parameters
- $object : Mage_Core_Model_Abstract
Tags
Return values
$this_construct()
protected
_construct() : mixed
Attributes
- #[Override]
_getAssociatedEntityInfo()
Retrieve correspondent entity information (associations table name, columns names) of rule's associated entity by specified entity type
protected
_getAssociatedEntityInfo(string $entityType) : array<string|int, mixed>
Parameters
- $entityType : string
Return values
array<string|int, mixed>_getConnection()
Get connection by name or type
protected
_getConnection(string $connectionName) : Varien_Db_Adapter_Pdo_Mysql
Parameters
- $connectionName : string
Return values
Varien_Db_Adapter_Pdo_Mysql_getLoadSelect()
Retrieve select object for load object data
protected
_getLoadSelect(string $field, mixed $value, Mage_Core_Model_Abstract $object) : Varien_Db_Select
Parameters
- $field : string
- $value : mixed
- $object : Mage_Core_Model_Abstract
Tags
Return values
Varien_Db_Select_getReadAdapter()
Retrieve connection for read data
protected
_getReadAdapter() : Varien_Db_Adapter_Pdo_Mysql
Attributes
- #[Override]
Return values
Varien_Db_Adapter_Pdo_Mysql_getWriteAdapter()
Retrieve connection for write data
protected
_getWriteAdapter() : Varien_Db_Adapter_Pdo_Mysql
Attributes
- #[Override]
Return values
Varien_Db_Adapter_Pdo_Mysql_init()
Standard resource model initialization
protected
_init(string $mainTable, string $idFieldName) : mixed
Parameters
- $mainTable : string
- $idFieldName : string
_initUniqueFields()
Initialize unique fields
protected
_initUniqueFields() : $this
Return values
$this_prepareDataForSave()
Prepare data for save
protected
_prepareDataForSave(Mage_Core_Model_Abstract $object) : array<string|int, mixed>
Parameters
- $object : Mage_Core_Model_Abstract
Return values
array<string|int, mixed>_prepareDataForTable()
Prepare data for passed table
protected
_prepareDataForTable(Varien_Object $object, string $table) : array<string|int, mixed>
Parameters
- $object : Varien_Object
- $table : string
Return values
array<string|int, mixed>_prepareTableValueForSave()
Prepare value for save
protected
_prepareTableValueForSave(mixed $value, string $type) : mixed
Parameters
- $value : mixed
- $type : string
_prepareValueForSave()
Prepare value for save
protected
_prepareValueForSave(mixed $value, string $type) : mixed
Parameters
- $value : mixed
- $type : string
_serializeField()
Serialize specified field in an object
protected
_serializeField(Varien_Object $object, string $field[, mixed $defaultValue = null ][, bool $unsetEmpty = false ]) : $this
Parameters
- $object : Varien_Object
- $field : string
- $defaultValue : mixed = null
- $unsetEmpty : bool = false
Return values
$this_serializeFields()
Serialize serializable fields of the object
protected
_serializeFields(Mage_Core_Model_Abstract $object) : mixed
Parameters
- $object : Mage_Core_Model_Abstract
_setMainTable()
Set main entity table name and primary key field name If field name is omitted {table_name}_id will be used
protected
_setMainTable(string $mainTable[, string|null $idFieldName = null ]) : $this
Parameters
- $mainTable : string
- $idFieldName : string|null = null
Return values
$this_setResource()
Initialize connections and tables for this resource model If one or both arguments are string, will be used as prefix If $tables is null and $connections is string, $tables will be the same
protected
_setResource(string|array<string|int, mixed> $connections[, string|array<string|int, mixed>|null $tables = null ]) : Mage_Core_Model_Resource_Abstract
Parameters
- $connections : string|array<string|int, mixed>
- $tables : string|array<string|int, mixed>|null = null
Return values
Mage_Core_Model_Resource_Abstract_unserializeField()
Unserialize Varien_Object field in an object
protected
_unserializeField(Varien_Object $object, string $field[, mixed $defaultValue = null ]) : mixed
Parameters
- $object : Varien_Object
- $field : string
- $defaultValue : mixed = null