Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Index_Adminhtml_ProcessController
  • Mage_Index_Block_Adminhtml_Notifications
  • Mage_Index_Block_Adminhtml_Process
  • Mage_Index_Block_Adminhtml_Process_Edit
  • Mage_Index_Block_Adminhtml_Process_Edit_Form
  • Mage_Index_Block_Adminhtml_Process_Edit_Tab_Main
  • Mage_Index_Block_Adminhtml_Process_Edit_Tabs
  • Mage_Index_Block_Adminhtml_Process_Grid
  • Mage_Index_Block_Adminhtml_Process_Grid_Massaction
  • Mage_Index_Helper_Data
  • Mage_Index_Model_Event
  • Mage_Index_Model_Indexer
  • Mage_Index_Model_Indexer_Abstract
  • Mage_Index_Model_Mysql4_Abstract
  • Mage_Index_Model_Mysql4_Event
  • Mage_Index_Model_Mysql4_Event_Collection
  • Mage_Index_Model_Mysql4_Process
  • Mage_Index_Model_Mysql4_Process_Collection
  • Mage_Index_Model_Mysql4_Setup
  • Mage_Index_Model_Observer
  • Mage_Index_Model_Process
  • Mage_Index_Model_Resource_Abstract
  • Mage_Index_Model_Resource_Event
  • Mage_Index_Model_Resource_Event_Collection
  • Mage_Index_Model_Resource_Helper_Mysql4
  • Mage_Index_Model_Resource_Process
  • Mage_Index_Model_Resource_Process_Collection
  • Mage_Index_Model_Resource_Setup
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Index
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Index Event Resource Model
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Index
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Index_Model_Resource_Event extends Mage_Core_Model_Resource_Db_Abstract
 36: {
 37:     /**
 38:      * Enter description here ...
 39:      *
 40:      */
 41:     protected function _construct()
 42:     {
 43:         $this->_init('index/event', 'event_id');
 44:     }
 45: 
 46:     /**
 47:      * Check if semilar event exist before start saving data
 48:      *
 49:      * @param Mage_Core_Model_Abstract $object
 50:      * @return Mage_Index_Model_Resource_Event
 51:      */
 52:     protected function _beforeSave(Mage_Core_Model_Abstract $object)
 53:     {
 54:         /**
 55:          * Check if event already exist and merge previous data
 56:          */
 57:         if (!$object->getId()) {
 58:             $select = $this->_getReadAdapter()->select()
 59:                 ->from($this->getMainTable())
 60:                 ->where('type=?', $object->getType())
 61:                 ->where('entity=?', $object->getEntity());
 62:             if ($object->hasEntityPk()) {
 63:                 $select->where('entity_pk=?', $object->getEntityPk());
 64:             }
 65:             $data = $this->_getWriteAdapter()->fetchRow($select);
 66:             if ($data) {
 67:                 $object->mergePreviousData($data);
 68:             }
 69:         }
 70:         $object->cleanNewData();
 71:         return parent::_beforeSave($object);
 72:     }
 73: 
 74:     /**
 75:      * Save assigned processes
 76:      *
 77:      * @param Mage_Core_Model_Abstract $object
 78:      * @return Mage_Index_Model_Resource_Event
 79:      */
 80:     protected function _afterSave(Mage_Core_Model_Abstract $object)
 81:     {
 82:         $processIds = $object->getProcessIds();
 83:         if (is_array($processIds)) {
 84:             $processTable = $this->getTable('index/process_event');
 85:             if (empty($processIds)) {
 86:                 $this->_getWriteAdapter()->delete($processTable);
 87:             } else {
 88:                 foreach ($processIds as $processId => $processStatus) {
 89:                     if (is_null($processStatus) || $processStatus == Mage_Index_Model_Process::EVENT_STATUS_DONE) {
 90:                         $this->_getWriteAdapter()->delete($processTable, array(
 91:                             'process_id = ?' => $processId,
 92:                             'event_id = ?'   => $object->getId(),
 93:                         ));
 94:                         continue;
 95:                     }
 96:                     $data = array(
 97:                         'process_id' => $processId,
 98:                         'event_id'   => $object->getId(),
 99:                         'status'     => $processStatus
100:                     );
101:                     $this->_getWriteAdapter()->insertOnDuplicate($processTable, $data, array('status'));
102:                 }
103:             }
104:         }
105:         return parent::_afterSave($object);
106:     }
107: 
108:     /**
109:      * Update status for events of process
110:      *
111:      * @param int|array|Mage_Index_Model_Process $process
112:      * @param string $status
113:      * @return Mage_Index_Model_Resource_Event
114:      */
115:     public function updateProcessEvents($process, $status = Mage_Index_Model_Process::EVENT_STATUS_DONE)
116:     {
117:         $whereCondition = '';
118:         if ($process instanceof Mage_Index_Model_Process) {
119:             $whereCondition = array('process_id = ?' => $process->getId());
120:         } elseif (is_array($process) && !empty($process)) {
121:             $whereCondition = array('process_id IN (?)' => $process);
122:         } elseif (!is_array($whereCondition)) {
123:             $whereCondition = array('process_id = ?' => $process);
124:         }
125:         $this->_getWriteAdapter()->update(
126:             $this->getTable('index/process_event'),
127:             array('status' => $status),
128:             $whereCondition
129:         );
130:         return $this;
131:     }
132: 
133:     /**
134:      * Retrieve unprocessed events list by specified process
135:      *
136:      * @param Mage_Index_Model_Process $process
137:      * @return array
138:      */
139:     public function getUnprocessedEvents($process)
140:     {
141:         $select = $this->_getReadAdapter()->select()
142:             ->from($this->getTable('index/process_event'))
143:             ->where('process_id = ?', $process->getId())
144:             ->where('status = ?', Mage_Index_Model_Process::EVENT_STATUS_NEW);
145: 
146:         return $this->_getReadAdapter()->fetchAll($select);
147:     }
148: }
149: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0