Public Member Functions | |
_construct () | |
addOptionValueToCollection ($collection, $attribute, $valueExpr) | |
getFlatUpdateSelect (Mage_Eav_Model_Entity_Attribute_Abstract $attribute, $store, $hasValueField=true) |
Definition at line 34 of file Option.php.
_construct | ( | ) |
Resource initialization
Reimplemented from Mage_Core_Model_Resource_Abstract.
Definition at line 36 of file Option.php.
00037 { 00038 $this->_init('eav/attribute_option', 'option_id'); 00039 }
addOptionValueToCollection | ( | $ | collection, | |
$ | attribute, | |||
$ | valueExpr | |||
) |
Add Join with option value for collection select
Mage_Eav_Model_Entity_Collection_Abstract | $collection | |
Mage_Eav_Model_Entity_Attribute | $attribute | |
Zend_Db_Expr | $valueExpr |
Definition at line 50 of file Option.php.
00050 { 00051 $attributeCode = $attribute->getAttributeCode(); 00052 $optionTable1 = $attributeCode . '_option_value_t1'; 00053 $optionTable2 = $attributeCode . '_option_value_t2'; 00054 00055 $collection->getSelect() 00056 ->joinLeft( 00057 array($optionTable1 => $this->getTable('eav/attribute_option_value')), 00058 "`{$optionTable1}`.`option_id`={$valueExpr}" 00059 . " AND `{$optionTable1}`.`store_id`='0'", 00060 array()) 00061 ->joinLeft( 00062 array($optionTable2 => $this->getTable('eav/attribute_option_value')), 00063 "`{$optionTable2}`.`option_id`={$valueExpr}" 00064 . " AND `{$optionTable1}`.`store_id`='{$collection->getStoreId()}'", 00065 array($attributeCode => "IFNULL(`{$optionTable2}`.`value`, `{$optionTable1}`.`value`)") 00066 ); 00067 00068 return $this; 00069 }
getFlatUpdateSelect | ( | Mage_Eav_Model_Entity_Attribute_Abstract $ | attribute, | |
$ | store, | |||
$ | hasValueField = true | |||
) |
Retrieve Select for update Flat data
Mage_Eav_Model_Entity_Attribute_Abstract | $attribute | |
int | $store | |
bool | $hasValueField flag which require option value |
Definition at line 79 of file Option.php.
00080 { 00081 $attributeTable = $attribute->getBackend()->getTable(); 00082 $attributeCode = $attribute->getAttributeCode(); 00083 00084 $joinCondition = "`e`.`entity_id`=`t1`.`entity_id`"; 00085 if ($attribute->getFlatAddChildData()) { 00086 $joinCondition .= " AND `e`.`child_id`=`t1`.`entity_id`"; 00087 } 00088 00089 $valueExpr = new Zend_Db_Expr("IFNULL(t2.value, t1.value)"); 00090 $select = $this->_getReadAdapter()->select() 00091 ->joinLeft( 00092 array('t1' => $attributeTable), 00093 $joinCondition, 00094 array() 00095 ) 00096 ->joinLeft( 00097 array('t2' => $attributeTable), 00098 "`t2`.`entity_id`=`t1`.`entity_id`" 00099 . " AND `t1`.`entity_type_id`=`t2`.`entity_type_id`" 00100 . " AND `t1`.`attribute_id`=`t2`.`attribute_id`" 00101 . " AND `t2`.`store_id`={$store}", 00102 array($attributeCode => $valueExpr)); 00103 if (($attribute->getFrontend()->getInputType() != 'multiselect') && $hasValueField) { 00104 $select->joinLeft( 00105 array('to1' => $this->getTable('eav/attribute_option_value')), 00106 "`to1`.`option_id`={$valueExpr}" 00107 . " AND `to1`.`store_id`='0'", 00108 array()) 00109 ->joinLeft( 00110 array('to2' => $this->getTable('eav/attribute_option_value')), 00111 "`to2`.`option_id`={$valueExpr}" 00112 . " AND `to2`.`store_id`='{$store}'", 00113 array($attributeCode . '_value' => "IFNULL(`to2`.`value`, `to1`.`value`)") 00114 ); 00115 } 00116 $select 00117 ->where('t1.entity_type_id=?', $attribute->getEntityTypeId()) 00118 ->where('t1.attribute_id=?', $attribute->getId()) 00119 ->where('t1.store_id=?', 0); 00120 00121 if ($attribute->getFlatAddChildData()) { 00122 $select->where("e.is_child=?", 0); 00123 } 00124 return $select; 00125 }