Public Member Functions | |
setStore ($store) | |
setStoreId ($storeId) | |
getStoreId () | |
getDefaultStoreId () | |
Protected Member Functions | |
_getLoadAttributesSelect ($table, $attributeIds=array()) | |
_joinAttributeToSelect ($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias) | |
Protected Attributes | |
$_storeId = null |
Definition at line 36 of file Abstract.php.
_getLoadAttributesSelect | ( | $ | table, | |
$ | attributeIds = array() | |||
) | [protected] |
Retrieve attributes load select
string | $table |
Reimplemented from Mage_Eav_Model_Entity_Collection_Abstract.
Definition at line 74 of file Abstract.php.
00075 { 00076 if (empty($attributeIds)) { 00077 $attributeIds = $this->_selectAttributes; 00078 } 00079 if ((int) $this->getStoreId()) { 00080 $entityIdField = $this->getEntity()->getEntityIdField(); 00081 $joinCondition = 'store.attribute_id=default.attribute_id 00082 AND store.entity_id=default.entity_id 00083 AND store.store_id='.(int) $this->getStoreId(); 00084 00085 $select = $this->getConnection()->select() 00086 ->from(array('default'=>$table), array($entityIdField, 'attribute_id', 'default_value'=>'value')) 00087 ->joinLeft( 00088 array('store'=>$table), 00089 $joinCondition, 00090 array( 00091 'store_value' => 'value', 00092 'value' => new Zend_Db_Expr('IFNULL(store.value, default.value)') 00093 ) 00094 ) 00095 ->where('default.entity_type_id=?', $this->getEntity()->getTypeId()) 00096 ->where("default.$entityIdField in (?)", array_keys($this->_itemsById)) 00097 ->where('default.attribute_id in (?)', $attributeIds) 00098 ->where('default.store_id = 0'); 00099 } 00100 else { 00101 $select = parent::_getLoadAttributesSelect($table) 00102 ->where('store_id=?', $this->getDefaultStoreId()); 00103 } 00104 return $select; 00105 }
_joinAttributeToSelect | ( | $ | method, | |
$ | attribute, | |||
$ | tableAlias, | |||
$ | condition, | |||
$ | fieldCode, | |||
$ | fieldAlias | |||
) | [protected] |
Initialize entity ubject property value
$valueInfo is _getLoadAttributesSelect fetch result row
array | $valueInfo |
string | $method | |
object | $attribute | |
string | $tableAlias | |
array | $condition | |
string | $fieldCode | |
string | $fieldAlias |
Add joining default value for not default store if value for store is null - we use default value
Reimplemented from Mage_Eav_Model_Entity_Collection_Abstract.
Definition at line 141 of file Abstract.php.
00142 { 00143 if (isset($this->_joinAttributes[$fieldCode]['store_id'])) { 00144 $store_id = $this->_joinAttributes[$fieldCode]['store_id']; 00145 } 00146 else { 00147 $store_id = $this->getStoreId(); 00148 } 00149 00150 if ($store_id != $this->getDefaultStoreId() && !$attribute->isScopeGlobal()) { 00151 /** 00152 * Add joining default value for not default store 00153 * if value for store is null - we use default value 00154 */ 00155 $defCondition = '('.join(') AND (', $condition).')'; 00156 $defAlias = $tableAlias.'_default'; 00157 $defFieldCode = $fieldCode.'_default'; 00158 $defFieldAlias= str_replace($tableAlias, $defAlias, $fieldAlias); 00159 00160 $defCondition = str_replace($tableAlias, $defAlias, $defCondition); 00161 $defCondition.= $this->getConnection()->quoteInto(" AND $defAlias.store_id=?", $this->getDefaultStoreId()); 00162 00163 $this->getSelect()->$method( 00164 array($defAlias => $attribute->getBackend()->getTable()), 00165 $defCondition, 00166 array() 00167 ); 00168 00169 $method = 'joinLeft'; 00170 $fieldAlias = new Zend_Db_Expr("IFNULL($fieldAlias, $defFieldAlias)"); 00171 $this->_joinAttributes[$fieldCode]['condition_alias'] = $fieldAlias; 00172 $this->_joinAttributes[$fieldCode]['attribute'] = $attribute; 00173 } 00174 else { 00175 $store_id = $this->getDefaultStoreId(); 00176 } 00177 $condition[] = $this->getConnection()->quoteInto("$tableAlias.store_id=?", $store_id); 00178 return parent::_joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias); 00179 }
getDefaultStoreId | ( | ) |
Definition at line 63 of file Abstract.php.
00064 { 00065 return Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID; 00066 }
getStoreId | ( | ) |
Definition at line 55 of file Abstract.php.
00056 { 00057 if (is_null($this->_storeId)) { 00058 $this->setStoreId(Mage::app()->getStore()->getId()); 00059 } 00060 return $this->_storeId; 00061 }
setStore | ( | $ | store | ) |
Reimplemented in Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection.
Definition at line 40 of file Abstract.php.
00041 { 00042 $this->setStoreId(Mage::app()->getStore($store)->getId()); 00043 return $this; 00044 }
setStoreId | ( | $ | storeId | ) |
Definition at line 46 of file Abstract.php.
00047 { 00048 if ($storeId instanceof Mage_Core_Model_Store) { 00049 $storeId = $storeId->getId(); 00050 } 00051 $this->_storeId = $storeId; 00052 return $this; 00053 }
$_storeId = null [protected] |
Definition at line 38 of file Abstract.php.