Public Member Functions | |
__construct () | |
getEntityTypeIdsToTypes () | |
getEntityIdsToIncrementIds () | |
getCoreResource () | |
getAllOrderEntityTypeIds () | |
getAllOrderEntityIds ($oid, $orderEntityTypes) | |
getAllEntityIds ($entityIds=array()) | |
getAllEntityTypeCommentIds () | |
getAllCommentCollection ($oid) | |
Protected Attributes | |
$_entityTypeIdsToTypes | |
$_entityIdsToIncrementIds |
Definition at line 33 of file Order.php.
__construct | ( | ) |
getAllCommentCollection | ( | $ | oid | ) |
Definition at line 187 of file Order.php.
00188 { 00189 $orderEntityTypes = $this->getAllOrderEntityTypeIds(); 00190 $entityIds = $this->getAllOrderEntityIds($oid, $orderEntityTypes); 00191 $allEntityIds = $this->getAllEntityIds($entityIds); 00192 00193 $eTypes = $this->getAllEntityTypeCommentIds(); 00194 $etypeIds = implode(',',$eTypes['entityTypeIds']); 00195 00196 /*foreach($entityTypeIds as $eid=>$result){ 00197 $etIds[] = $eid; 00198 $attributeIds[] = $result['comment_attribute_id']; 00199 $attributeIds[] = $result['notified_attribute_id']; 00200 }*/ 00201 00202 $res = $this->getCoreResource(); 00203 $read = $res->getConnection('core_read'); 00204 $select = $read->select() 00205 ->from(array('order' => $res->getTableName('sales/order')), array('entity_id','created_at','entity_type_id','parent_id')) 00206 ->where('order.entity_id in ('.implode(",", $allEntityIds).')') 00207 ->join($eTypes['comment_table'],"{$eTypes['comment_table']}.entity_id=order.entity_id 00208 and {$eTypes['comment_table']}.attribute_id in (".implode(',',$eTypes['commentAttrIds']).") 00209 and {$eTypes['comment_table']}.entity_type_id in (".$etypeIds.")" 00210 ,array('comment' => "{$eTypes['comment_table']}.value")) 00211 ->join($eTypes['notified_table'],"{$eTypes['notified_table']}.entity_id=order.entity_id 00212 and {$eTypes['notified_table']}.attribute_id in (".implode(',',$eTypes['notifiedAttrIds']).") 00213 and {$eTypes['notified_table']}.entity_type_id in (".$etypeIds.") and {$eTypes['notified_table']}.value=1" 00214 ,array('notified' =>"{$eTypes['notified_table']}.value")) 00215 ->order('created_at desc') 00216 ; 00217 return $read->fetchAll($select); 00218 00219 }
getAllEntityIds | ( | $ | entityIds = array() |
) |
Definition at line 109 of file Order.php.
00110 { 00111 $res = $this->getCoreResource(); 00112 $read = $res->getConnection('core_read'); 00113 $entityIdStr = implode(',', $entityIds); 00114 $select = $read->select() 00115 ->from($res->getTableName('sales/order'), array('entity_id','increment_id')) 00116 ->where('parent_id in (' .$entityIdStr.')') 00117 ->orWhere('entity_id in (' .$entityIdStr.')'); 00118 $results = $read->fetchAll($select); 00119 $eIds = array(); 00120 foreach($results as $result){ 00121 if($result['increment_id']) { 00122 $this->_entityIdsToIncrementIds[$result['entity_id']] = $result['increment_id']; 00123 } 00124 $eIds[] = $result['entity_id']; 00125 } 00126 return $eIds; 00127 }
getAllEntityTypeCommentIds | ( | ) |
Definition at line 129 of file Order.php.
00130 { 00131 $entityTypes = array(); 00132 $eav = Mage::getSingleton('eav/config'); 00133 $etypeIds = array(); 00134 $cattrIds = array(); 00135 $nattrIds = array(); 00136 $cTable = ''; 00137 $nTable = ''; 00138 foreach (array( 00139 'order_status_history'=>array('model' => 'sales/order_status_history', 'type' => 'order'), 00140 'invoice_comment'=>array('model' => 'sales/order_invoice_comment', 'type' => 'invoice'), 00141 'shipment_comment'=>array('model' => 'sales/order_shipment_comment', 'type' => 'shipment'), 00142 'creditmemo_comment'=>array('model' => 'sales/order_creditmemo_comment', 'type' => 'creditmemo') 00143 ) as $entityTypeCode=>$entityArr) { 00144 00145 $entityType = $eav->getEntityType($entityTypeCode); 00146 $entity = Mage::getResourceSingleton($entityArr['model']); 00147 $commentAttr = $eav->getAttribute($entityType, 'comment'); 00148 $notifiedAttr = $eav->getAttribute($entityType, 'is_customer_notified'); 00149 $statusAttr = $eav->getAttribute($entityType, 'status'); 00150 #$statusAttr->setEntity($entity); 00151 #echo "****".$statusAttr->getBackend()->getTable()."****".$statusAttr->getId(); 00152 if (!$cTable) { 00153 $commentAttr->setEntity($entity); 00154 $cTable = $commentAttr->getBackend()->getTable(); 00155 } 00156 if (!$nTable) { 00157 $notifiedAttr->setEntity($entity); 00158 $nTable = $notifiedAttr->getBackend()->getTable(); 00159 } 00160 $etypeIds[] = $entityType->getId(); 00161 $cattrIds[] = $commentAttr->getId(); 00162 $nattrIds[] = $notifiedAttr->getId(); 00163 $this->_entityTypeIdsToTypes[$entityType->getId()] = $entityArr['type']; 00164 /* 00165 $entityTypes[$entityType->getId()] = array( 00166 'table'=>$entityType->getEntityTable(), 00167 'alias' => $entityTypeCode, 00168 'comment_attribute_id'=>$commentAttr->getId(), 00169 'notified_attribute_id'=>$notifiedAttr->getId(), 00170 ); 00171 */ 00172 } 00173 $entityTypes = array( 00174 'entityTypeIds' => $etypeIds, 00175 'commentAttrIds' => $cattrIds, 00176 'notifiedAttrIds' => $nattrIds, 00177 'comment_table' => $cTable, 00178 'notified_table' => $nTable); 00179 return $entityTypes; 00180 }
getAllOrderEntityIds | ( | $ | oid, | |
$ | orderEntityTypes | |||
) |
Definition at line 89 of file Order.php.
00090 { 00091 $etypeIdsArr = array_keys($orderEntityTypes['entityTypeIds']); 00092 $res = $this->getCoreResource(); 00093 $read = $res->getConnection('core_read'); 00094 $select = $read->select() 00095 ->from(array('order' => $res->getTableName('sales/order')), array('entity_id')) 00096 ->join($orderEntityTypes['order_table'],"{$orderEntityTypes['order_table']}.entity_id=order.entity_id 00097 and {$orderEntityTypes['order_table']}.attribute_id in (".implode(',',$orderEntityTypes['orderAttrIds']).") 00098 and {$orderEntityTypes['order_table']}.entity_type_id in (".implode(',', $etypeIdsArr).") and {$orderEntityTypes['order_table']}.value={$oid}" 00099 ,array("{$orderEntityTypes['order_table']}.value")); 00100 00101 $results = $read->fetchAll($select); 00102 $eIds = array($oid); 00103 foreach($results as $result){ 00104 $eIds[] = $result['entity_id']; 00105 } 00106 return $eIds; 00107 }
getAllOrderEntityTypeIds | ( | ) |
Definition at line 59 of file Order.php.
00060 { 00061 $orderEntityTypes = array(); 00062 $etypeIds = array(); 00063 $oattrIds = array(); 00064 $eav = Mage::getSingleton('eav/config'); 00065 $oTable = ''; 00066 foreach (array( 00067 'invoice'=>'sales/order_invoice', 00068 'shipment'=>'sales/order_shipment', 00069 'creditmemo'=>'sales/order_creditmemo' 00070 ) as $entityTypeCode=>$entityModel) { 00071 $entityType = $eav->getEntityType($entityTypeCode); 00072 $entity = Mage::getResourceSingleton($entityModel); 00073 $orderAttr = $eav->getAttribute($entityType, 'order_id'); 00074 if (!$oTable) { 00075 $orderAttr->setEntity($entity); 00076 $oTable = $orderAttr->getBackend()->getTable(); 00077 } 00078 $this->_entityTypeIdsToTypes[$entityType->getId()] = $entityTypeCode; 00079 $etypeIds[$entityType->getId()] = $entityTypeCode; 00080 $oattrIds[] = $orderAttr->getId(); 00081 } 00082 $orderEntityTypes = array( 00083 'entityTypeIds' => $etypeIds, 00084 'orderAttrIds' => $oattrIds, 00085 'order_table' => $oTable); 00086 return $orderEntityTypes; 00087 }
getCoreResource | ( | ) |
Definition at line 54 of file Order.php.
00055 { 00056 return Mage::getSingleton('core/resource'); 00057 }
getEntityIdsToIncrementIds | ( | ) |
getEntityTypeIdsToTypes | ( | ) |