Definition at line 34 of file Item.php.
_beforeSave | ( | ) | [protected] |
Prepare data before save
Reimplemented from Mage_Core_Model_Abstract.
Definition at line 75 of file Item.php.
00076 { 00077 parent::_beforeSave(); 00078 if (!$this->getOrderId()) { 00079 $this->setOrderId($this->getOrder()->getId()); 00080 } 00081 if ($this->getParentItem()) { 00082 $this->setParentItemId($this->getParentItem()->getId()); 00083 } 00084 return $this; 00085 }
_construct | ( | ) | [protected] |
Init resource model
Reimplemented from Varien_Object.
Definition at line 65 of file Item.php.
00066 { 00067 $this->_init('sales/order_item'); 00068 }
addChildItem | ( | $ | item | ) |
Adds child item to this item
Mage_Sales_Model_Order_Item | $item |
Definition at line 417 of file Item.php.
00418 { 00419 if ($item instanceof Mage_Sales_Model_Order_Item) { 00420 $this->_children[] = $item; 00421 } else if (is_array($item)) { 00422 $this->_children = array_merge($this->_children, $item); 00423 } 00424 }
cancel | ( | ) |
Cancel order item
Definition at line 308 of file Item.php.
00309 { 00310 if ($this->getStatusId() !== self::STATUS_CANCELED) { 00311 Mage::dispatchEvent('sales_order_item_cancel', array('item'=>$this)); 00312 $this->setQtyCanceled($this->getQtyToCancel()); 00313 } 00314 return $this; 00315 }
canInvoice | ( | ) |
Check item invoice availability
Definition at line 118 of file Item.php.
00119 { 00120 return $this->getQtyToInvoice()>0; 00121 }
canRefund | ( | ) |
Check item refund availability
Definition at line 138 of file Item.php.
00139 { 00140 return $this->getQtyToRefund()>0; 00141 }
canShip | ( | ) |
Check item ship availability
Definition at line 128 of file Item.php.
00129 { 00130 return $this->getQtyToShip()>0; 00131 }
getChildrenItems | ( | ) |
getOrder | ( | ) |
Retrieve order model object
Definition at line 221 of file Item.php.
00222 { 00223 if (is_null($this->_order) && ($orderId = $this->getOrderId())) { 00224 $order = Mage::getModel('sales/order'); 00225 $order->load($orderId); 00226 $this->setOrder($order); 00227 } 00228 return $this->_order; 00229 }
getOriginalPrice | ( | ) |
getParentItem | ( | ) |
Get parent item
Definition at line 108 of file Item.php.
getProductOptionByCode | ( | $ | code = null |
) |
Get product options array by code. If code is null return all options
string | $code |
Definition at line 387 of file Item.php.
00388 { 00389 $options = $this->getProductOptions(); 00390 if (is_null($code)) { 00391 return $options; 00392 } 00393 if (isset($options[$code])) { 00394 return $options[$code]; 00395 } 00396 return null; 00397 }
getProductOptions | ( | ) |
getQtyToCancel | ( | ) |
Retrieve item qty available for cancel
Definition at line 197 of file Item.php.
00198 { 00199 $qtyToCancel = min($this->getQtyToInvoice(), $this->getQtyToShip()); 00200 return max($qtyToCancel, 0); 00201 }
getQtyToInvoice | ( | ) |
Retrieve item qty available for invoice
Definition at line 166 of file Item.php.
00167 { 00168 if ($this->isDummy()) { 00169 return 0; 00170 } 00171 00172 $qty = $this->getQtyOrdered() 00173 - $this->getQtyInvoiced() 00174 - $this->getQtyCanceled(); 00175 return max($qty, 0); 00176 }
getQtyToRefund | ( | ) |
getQtyToShip | ( | ) |
Retrieve item qty available for ship
Definition at line 148 of file Item.php.
00149 { 00150 if ($this->isDummy(true)) { 00151 return 0; 00152 } 00153 00154 $qty = $this->getQtyOrdered() 00155 - $this->getQtyShipped() 00156 - $this->getQtyRefunded() 00157 - $this->getQtyCanceled(); 00158 return max($qty, 0); 00159 }
getRealProductType | ( | ) |
Return real product type of item or NULL if item is not composite
Definition at line 404 of file Item.php.
00405 { 00406 if ($productType = $this->getProductOptionByCode('real_product_type')) { 00407 return $productType; 00408 } 00409 return null; 00410 }
getStatus | ( | ) |
Retrieve status
Definition at line 282 of file Item.php.
00283 { 00284 return $this->getStatusName($this->getStatusId()); 00285 }
static getStatuses | ( | ) | [static] |
Retrieve order item statuses array
Definition at line 322 of file Item.php.
00323 { 00324 if (is_null(self::$_statuses)) { 00325 self::$_statuses = array( 00326 //self::STATUS_PENDING => Mage::helper('sales')->__('Pending'), 00327 self::STATUS_PENDING => Mage::helper('sales')->__('Ordered'), 00328 self::STATUS_SHIPPED => Mage::helper('sales')->__('Shipped'), 00329 self::STATUS_INVOICED => Mage::helper('sales')->__('Invoiced'), 00330 self::STATUS_BACKORDERED => Mage::helper('sales')->__('Backordered'), 00331 self::STATUS_RETURNED => Mage::helper('sales')->__('Returned'), 00332 self::STATUS_REFUNDED => Mage::helper('sales')->__('Refunded'), 00333 self::STATUS_CANCELED => Mage::helper('sales')->__('Canceled'), 00334 self::STATUS_PARTIAL => Mage::helper('sales')->__('Partial'), 00335 self::STATUS_MIXED => Mage::helper('sales')->__('Mixed'), 00336 ); 00337 } 00338 return self::$_statuses; 00339 }
getStatusId | ( | ) |
Retrieve item status identifier
Definition at line 236 of file Item.php.
00237 { 00238 $backordered = (float)$this->getQtyBackordered(); 00239 $canceled = (float)$this->getQtyCanceled(); 00240 $invoiced = (float)$this->getQtyInvoiced(); 00241 $ordered = (float)$this->getQtyOrdered(); 00242 $refunded = (float)$this->getQtyRefunded(); 00243 $shipped = (float)$this->getQtyShipped(); 00244 00245 $actuallyOrdered = $ordered - $canceled - $refunded; 00246 00247 if (!$invoiced && !$shipped && !$refunded && !$canceled && !$backordered) { 00248 return self::STATUS_PENDING; 00249 } 00250 if ($shipped && !$invoiced && ($actuallyOrdered == $shipped)) { 00251 return self::STATUS_SHIPPED; 00252 } 00253 00254 if ($invoiced && !$shipped && ($actuallyOrdered == $invoiced)) { 00255 return self::STATUS_INVOICED; 00256 } 00257 00258 if ($backordered && ($actuallyOrdered == $backordered) ) { 00259 return self::STATUS_BACKORDERED; 00260 } 00261 00262 if ($refunded && $ordered == $refunded) { 00263 return self::STATUS_REFUNDED; 00264 } 00265 00266 if ($canceled && $ordered == $canceled) { 00267 return self::STATUS_CANCELED; 00268 } 00269 00270 if (max($shipped, $invoiced) < $actuallyOrdered) { 00271 return self::STATUS_PARTIAL; 00272 } 00273 00274 return self::STATUS_MIXED; 00275 }
static getStatusName | ( | $ | statusId | ) | [static] |
Retrieve status name
Definition at line 292 of file Item.php.
00293 { 00294 if (is_null(self::$_statuses)) { 00295 self::getStatuses(); 00296 } 00297 if (isset(self::$_statuses[$statusId])) { 00298 return self::$_statuses[$statusId]; 00299 } 00300 return Mage::helper('sales')->__('Unknown Status'); 00301 }
isChildrenCalculated | ( | ) |
Return checking of what calculation type was for this product
Definition at line 441 of file Item.php.
00441 { 00442 if ($parentItem = $this->getParentItem()) { 00443 $options = $parentItem->getProductOptions(); 00444 } else { 00445 $options = $this->getProductOptions(); 00446 } 00447 00448 if (isset($options['product_calculations']) && 00449 $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) { 00450 return true; 00451 } 00452 return false; 00453 }
isDummy | ( | $ | shipment = false |
) |
This is Dummy item or not if $shipment is true then we checking this for shipping situation if not then we checking this for calculation
bool | $shipment |
Definition at line 483 of file Item.php.
00483 { 00484 if ($shipment) { 00485 if ($this->getHasChildren() && $this->isShipSeparately()) { 00486 return true; 00487 } 00488 00489 if ($this->getHasChildren() && !$this->isShipSeparately()) { 00490 return false; 00491 } 00492 00493 if ($this->getParentItem() && $this->isShipSeparately()) { 00494 return false; 00495 } 00496 00497 if ($this->getParentItem() && !$this->isShipSeparately()) { 00498 return true; 00499 } 00500 } else { 00501 if ($this->getHasChildren() && $this->isChildrenCalculated()) { 00502 return true; 00503 } 00504 00505 if ($this->getHasChildren() && !$this->isChildrenCalculated()) { 00506 return false; 00507 } 00508 00509 if ($this->getParentItem() && $this->isChildrenCalculated()) { 00510 return false; 00511 } 00512 00513 if ($this->getParentItem() && !$this->isChildrenCalculated()) { 00514 return true; 00515 } 00516 } 00517 return false; 00518 }
isShipSeparately | ( | ) |
Return checking of what shipment type was for this product
Definition at line 461 of file Item.php.
00461 { 00462 if ($parentItem = $this->getParentItem()) { 00463 $options = $parentItem->getProductOptions(); 00464 } else { 00465 $options = $this->getProductOptions(); 00466 } 00467 00468 if (isset($options['shipment_type']) && 00469 $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) { 00470 return true; 00471 } 00472 return false; 00473 }
setOrder | ( | Mage_Sales_Model_Order $ | order | ) |
Declare order
Mage_Sales_Model_Order | $order |
Definition at line 209 of file Item.php.
00210 { 00211 $this->_order = $order; 00212 $this->setOrderId($order->getId()); 00213 return $this; 00214 }
setParentItem | ( | $ | item | ) |
Set parent item
Mage_Sales_Model_Order_Item | $item |
Definition at line 93 of file Item.php.
00094 { 00095 if ($item) { 00096 $this->_parentItem = $item; 00097 $item->setHasChildren(true); 00098 $item->addChildItem($this); 00099 } 00100 return $this; 00101 }
setProductOptions | ( | array $ | options | ) |
Set product options
array | $options |
Definition at line 361 of file Item.php.
$_eventObject = 'item' [protected] |
$_eventPrefix = 'sales_order_item' [protected] |
const STATUS_BACKORDERED = 3 |
const STATUS_CANCELED = 5 |
const STATUS_INVOICED = 9 |
const STATUS_MIXED = 7 |
const STATUS_PARTIAL = 6 |
const STATUS_PENDING = 1 |
const STATUS_REFUNDED = 8 |
const STATUS_RETURNED = 4 |
const STATUS_SHIPPED = 2 |