* All rights reserved * * Reuse or modification of this source code is not allowed * without written permission from creativestyle GmbH * * @category Creativestyle * @package Creativestyle_CheckoutByAmazon * @copyright Copyright (c) 2011 creativestyle GmbH (http://www.creativestyle.de) * @author Marek Zabrowarny / creativestyle GmbH */ class Creativestyle_CheckoutByAmazon_Model_Mysql4_Log_Feed extends Creativestyle_CheckoutByAmazon_Model_Mysql4_Log_Abstract { protected $_tableName = 'checkoutbyamazon/log_feed'; protected function _getApi() { return Mage::getSingleton('checkoutbyamazon/api_marketplace_feeds'); } protected function _afterLoad(Mage_Core_Model_Abstract $object) { parent::_afterLoad($object); $objectChanged = false; if (($object->getProcessingStatus() != '_DONE_') && $object->getSubmissionId()) { $feedSubmissionList = $this->_getApi()->getFeedSubmissionList(array($object->getSubmissionId())); if ($feedSubmissionList->issetFeedSubmissionInfo()) { $feedSubmissionInfo = $feedSubmissionList->getFeedSubmissionInfo(); if (is_array($feedSubmissionInfo)) { foreach ($feedSubmissionInfo as $_feed) { if ($_feed->issetFeedSubmissionId() && $_feed->issetFeedProcessingStatus() && ($_feed->getFeedSubmissionId() == $object->getSubmissionId()) && ($_feed->getFeedProcessingStatus() != $object->getProcessingStatus())) { $object->setProcessingStatus($_feed->getFeedProcessingStatus()); $objectChanged = true; } } } } } if ($object->getProcessingStatus() == '_DONE_' && is_null($object->getProcessingResult())) { try { $feedSubmissionResult = $this->_getApi()->getFeedSubmissionResult($object->getSubmissionId()); $object->setProcessingResult($feedSubmissionResult); $objectChanged = true; } catch (Exception $e) { // do not handle this exception, no result yet } } if ($objectChanged) $object->save(); return $this; } }