_monthStamp) $this->_monthStamp = date ("Y-m-d"); if (!$this->_timeStamp) $this->_timeStamp = date("H-i-s"); $logDir = sprintf ( "%s/%s/%s/%s/%s/", Mage::getBaseDir('var'), "/log/wexo_external/", "/$type/", $this->_monthStamp . "/", $this->_timeStamp . "/" ); mkdir ( $logDir, 0777, true ); file_put_contents ( $logDir.$filename,time().":". $msg."\n", FILE_APPEND ); } private function callMethod ( $prefix, $itemType, $params ) { $function = $prefix . $itemType; if ( method_exists ( $this, $function ) ) { return call_user_func ( array ( $this, $function ), $params ); } return array(); } public function convertDataEntry ( $entryType, $entry ) { if ( !$this->_disableLogging ) $this->logEvent ( $entryType, $entryType.".log", "convertDataEntry called" ); if ( !$this->_hasDataEvent[$entryType] ) { Mage::dispatchEvent ( 'integrations_convert_data_first_' . strtolower($entryType), array ( $this ) ); Mage::dispatchEvent ( 'integrations_convert_data_first', array ( 'object' => $this, 'datatype' => $entryType ) ); $this->_hasDataEvent[$entryType] = true; } try { $data = $this->callMethod ( "convert", $entryType, $entry ); return $data; } catch ( Exception $e ) { $this->logEvent ( $entryType, $entryType.".exception.log", "convertDataEntry, data:" . var_export ( $entry->getData(), true ) . ", exception:" . $e->getMessage() ); Mage::dispatchEvent ( 'integrations_exception', array ( 'exception' => $e, 'adapter' => $this, 'itemtype' => $itemType ) ); } } public function getItems ( $itemType ) { if ( !$this->_disableLogging ) $this->logEvent ( $itemType, $itemType.".log", "getItems called" ); try { return $this->callMethod ( "get", $itemType ); } catch ( Exception $e ) { $this->logEvent ( $itemType, $itemType.".exception.log", "getItems, exception:" . $e->getMessage() ); Mage::dispatchEvent ( 'integrations_exception', array ( 'exception' => $e, 'adapter' => $this, 'itemtype' => $itemType ) ); } } public function putItems ( $items, $itemType ) { if ( !$this->_disableLogging && !( is_array($items) && !count($items) ) ) { $logMsg = "putItems called, "; foreach ( $items as $item ) { $logMsg .= "item: "; if ( $item instanceof Varien_Object ) $logMsg .= var_export($item->getData(),true); else $logMsg .= var_export($item,true); $this->logEvent ( $itemType, $itemType.".log", $logMsg ); } } try { return $this->callMethod ( "put", $itemType, $items ); } catch ( Exception $e ) { $this->logEvent ( $itemType, $itemType.".exception.log", "putItems, data:" . var_export ( $items, true).", exception:" . $e->getMessage() ); Mage::dispatchEvent ( 'integrations_exception', array ( 'exception' => $e, 'adapter' => $this, 'itemtype' => $itemType ) ); } } }