/**
  * After save handler
  * @return
  */
 public function _afterSave()
 {
     if (!empty($this->_virtualItems)) {
         // Save virtual items
         foreach ($this->_virtualItems as $Item) {
             $Item->setSubscriptionId($this->getId())->save();
         }
     }
     if ($this->isActive() && ($this->getIsReactivated() || $this->getIsNew())) {
         foreach ($this->getItems() as $item) {
             if (($product = Mage::getModel('catalog/product')->load($item->getOrderItem()->getProductId())) && $product->getAwSarpIncludeToGroup() > 0) {
                 if ($this->getCustomer() instanceof Mage_Customer_Model_Customer) {
                     $this->getCustomer()->setGroupId($product->getAwSarpIncludeToGroup())->save();
                 }
             }
         }
     } elseif ($this->getIsStopping()) {
         foreach ($this->getItems() as $item) {
             if (($product = Mage::getModel('catalog/product')->load($item->getOrderItem()->getProductId())) && $product->getAwSarpExcludeToGroup() > 0) {
                 if ($this->getCustomer() instanceof Mage_Customer_Model_Customer) {
                     $this->getCustomer()->setGroupId($product->getAwSarpExcludeToGroup())->save();
                 }
             }
         }
     }
     if (!$this->getFlagNoSequenceUpdate()) {
         $this->_generateSubscriptionEvents();
     }
     // Set also customer details to flat data table
     $flat = Mage::getModel('sarp/subscription_flat')->load($this->getId(), 'subscription_id')->setSubscription($this)->save();
     $this->setFlatNextDeliveryDate($flat->getFlatNextDeliveryDate());
     $this->_generateAlertEvents();
     return parent::_afterSave();
 }
 /**
  * Save also information to flat table
  * @return AW_Helpdeskultimate_Model_Ticket
  */
 public function _afterSave()
 {
     $flat = Mage::getModel('helpdeskultimate/ticket_flat')->load($this->getId(), 'ticket_id')->setTicket($this)->save();
     if (!$this->getSkipStatusHistory() && @$this->_origData['status'] && $this->_data['status'] != $this->_origData['status']) {
         // Status changed. Save to history.
         Mage::getModel('awcore/logger')->setData(array('title' => "Ticket #{$this->getUid()} status changed to '{$this->getStatusText()}'" . " by '{$this->getDepartment()->getName()}'", 'module' => 'Helpdeskultimate', 'object' => 'AW_Helpdeskultimate_Model_Ticket', 'code' => 'AW_HDU_STATUS_CHANGE', 'custom_field_1' => $this->getId(), 'custom_field_2' => $this->getStatus(), 'custom_field_3' => $this->getDepartment()->getId(), 'custom_field_4' => (int) $this->getIsChangedByCustomer()))->save();
         $this->_origData['status'] = $this->_data['status'];
     }
     return parent::_afterSave();
 }