Mage_Adminhtml_Model_Sales_Order Class Reference

List of all members.

Public Member Functions

 checkRelation (Mage_Sales_Model_Order $order)

Protected Member Functions

 _getSession ()


Detailed Description

Definition at line 34 of file Order.php.


Member Function Documentation

_getSession (  )  [protected]

Retrieve adminhtml session singleton

Returns:
Mage_Adminhtml_Model_Session

Definition at line 41 of file Order.php.

00042     {
00043         return Mage::getSingleton('adminhtml/session');
00044     }

checkRelation ( Mage_Sales_Model_Order order  ) 

Check customer existing

Check Item products existing

Definition at line 46 of file Order.php.

00047     {
00048         /**
00049          * Check customer existing
00050          */
00051         $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
00052         if (!$customer->getId()) {
00053             $this->_getSession()->addNotice(
00054                 Mage::helper('adminhtml')->__(' The customer doesn\'t exist in the system anymore')
00055             );
00056         }
00057 
00058         /**
00059          * Check Item products existing
00060          */
00061         $productIds = array();
00062         foreach ($order->getAllItems() as $item) {
00063             $productIds[] = $item->getProductId();
00064         }
00065 
00066         $productCollection = Mage::getModel('catalog/product')->getCollection()
00067             ->addIdFilter($productIds)
00068             ->load();
00069 
00070         $hasBadItems = false;
00071         foreach ($order->getAllItems() as $item) {
00072             if (!$productCollection->getItemById($item->getProductId())) {
00073                 $this->_getSession()->addError(
00074                    Mage::helper('adminhtml')->__('The item %s (SKU %s) doesn\'t exist in the catalog anymore',
00075                        $item->getName(),
00076                        $item->getSku()
00077                 ));
00078                 $hasBadItems = true;
00079             }
00080         }
00081         if ($hasBadItems) {
00082             $this->_getSession()->addError(
00083                 Mage::helper('adminhtml')->__('Some of the ordered items don\'t exist in the catalog anymore and will be removed if you try to edit the order.')
00084             );
00085         }
00086         return $this;
00087     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:12 2009 for Magento by  doxygen 1.5.8