Example #1
0
 public function testGetCorrelationIdInbound()
 {
     $this->_object->resetHeaders();
     $this->_object->setHeaders(array('x-xc-result-correlation-id' => 'test2'));
     $correlationId = $this->_object->getCorrelationId();
     $this->assertEquals('test2', $correlationId);
 }
Example #2
0
 /**
  * Process data on message received
  * @return Xcom_Chronicle_Model_Message_Saleschannel_Sites_Inbound
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     if (!isset($data)) {
         $data = array();
     }
     if (!isset($data['webStoreId'])) {
         $data['webStoreId'] = '';
     }
     $webStoreId = $data['webStoreId'];
     try {
         if ($this->_validateSchema()) {
             $resultSet = $this->_processSearchCategories($webStoreId);
             if (!empty($resultSet['results'])) {
                 $response = $this->_generateSuccessMessage($webStoreId, $resultSet['results']);
                 Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreMetadataProvision/GetAllCategorySucceeded', $response);
             } else {
                 $response = $this->_generateFailureMessage($webStoreId, $resultSet['error']);
                 Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreMetadataProvision/GetAllCategoryFailed', $response);
             }
         }
     } catch (Exception $ex) {
         Mage::logException($ex);
         $response = $this->_generateFailureMessage($webStoreId, $ex->getMessage());
         Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreMetadataProvision/GetAllCategoryFailed', $response);
     }
     return $this;
 }
Example #3
0
 /**
  * Builds the Get success and/or failure outbound messages.
  * @return Xcom_Chronicle_Model_Message_Inventory_Stock_Get_Inbound this message
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     if (!isset($data)) {
         $data = array();
     }
     try {
         if ($this->_validateSchema()) {
             $resultSet = $this->_processLookup($data);
             $customer = $resultSet['customer'];
             if (!is_null($customer)) {
                 $response = array('customer' => $customer, 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
                 $this->_sendSuccess($response);
             }
             if (sizeof($resultSet['errors']) > 0) {
                 $response = array('errors' => $resultSet['errors'], 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
                 $this->_sendFailure($response);
             }
         }
     } catch (Exception $ex) {
         Mage::logException($ex);
         $errorResponse = array('id' => $data['id'], 'errors' => array(array('code' => empty($code) ? '-1' : '' . $code, 'message' => $ex->getMessage(), 'parameters' => null)), 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
         $this->_sendFailure($errorResponse);
     }
     return $this;
 }
Example #4
0
 /**
  * Process data on message received
  * @return Xcom_Chronicle_Model_Message_Saleschannel_Search_Inbound
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     if (!isset($data)) {
         $data = array();
     }
     if (!isset($data['query'])) {
         $data['query'] = null;
     }
     try {
         if ($this->_validateSchema()) {
             $results = $this->_processSearchQuery($data);
             $response = array('offers' => $results, 'query' => $data['query'], 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
             Mage::helper('xcom_xfabric')->send('salesChannel/offer/searchSucceeded', $response);
         }
     } catch (Xcom_Xfabric_Exception $ex) {
         Mage::logException($ex);
         $errorResponse = $this->_generate_failure_data($data['query'], $ex, $ex->getCode());
         Mage::helper('xcom_xfabric')->send('salesChannel/offer/searchFailed', $errorResponse);
         Mage::helper("Sent failure");
     } catch (Exception $ex) {
         Mage::logException($ex);
         if (!is_null($ex)) {
             $message = $ex->getMessage();
         }
         $errorResponse = $this->_generate_failure_data($data['query'], $ex);
         Mage::helper('xcom_xfabric')->send('salesChannel/offer/searchFailed', $errorResponse);
     }
     return $this;
 }
Example #5
0
 /**
  * Process data on message received
  * @return array
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     Mage::log($data, null, 'messageFailed.log');
     return $this;
 }
Example #6
0
 /**
  * Process data on message received
  * @return Xcom_Chronicle_Model_Message_Order_Search_Inbound
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     if (!isset($data)) {
         $data = array();
     }
     try {
         if ($this->_validateSchema()) {
             $results = $this->_processSearchQuery($data);
             $response = array('orders' => $results, 'query' => $data['query'], 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
             Mage::helper('xcom_xfabric')->send('com.x.ordermanagement.v2/OrderSearch.NonSensitive/SearchNonSensitiveOrderSucceeded', $response);
         }
     } catch (Xcom_Xfabric_Exception $ex) {
         Mage::logException($ex);
         $errorResponse = $this->_generateFailureData($data['query'], $ex, $ex->getCode());
         Mage::helper('xcom_xfabric')->send('com.x.ordermanagement.v2/OrderSearch.NonSensitive/SearchOrderFailed', $errorResponse);
         Mage::helper("Sent failure");
     } catch (Exception $ex) {
         Mage::logException($ex);
         $errorResponse = $this->_generateFailureData($data['query'], $ex);
         Mage::helper('xcom_xfabric')->send('com.x.ordermanagement.v2/OrderSearch.NonSensitive/SearchOrderFailed', $errorResponse);
     }
     return $this;
 }
Example #7
0
 /**
  * Builds the Get success and/or failure outbound messages.
  * @return Xcom_Chronicle_Model_Message_Inventory_Stock_Get_Inbound this message
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     if (!isset($data)) {
         $data = array();
     }
     try {
         if ($this->_validateSchema()) {
             $resultSet = $this->_processLookup($data);
             if (sizeof($resultSet['results']) > 0) {
                 $response = array('stockItems' => $resultSet['results'], 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
                 Mage::helper('xcom_xfabric')->send('com.x.inventory.v1/StockItemLookup/LookupStockItemSucceeded', $response);
             }
             if (sizeof($resultSet['errors']) > 0) {
                 $response = array('errors' => $resultSet['errors'], 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
                 Mage::helper('xcom_xfabric')->send('com.x.inventory.v1/StockItemLookup/LookupStockItemFailed', $response);
             }
         }
     } catch (Exception $ex) {
         Mage::logException($ex);
         $errors = array();
         foreach ($data['stockItemIds'] as $id) {
             $errors[] = array('sku' => $id, 'errors' => array(array('code' => '-1', 'message' => 'Exception raised while processing lookup for inventory.', 'parameters' => null)));
         }
         $response = array('errors' => $errors, 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
         Mage::helper('xcom_xfabric')->send('com.x.inventory.v1/StockItemLookup/LookupStockItemFailed', $response);
     }
     return $this;
 }
Example #8
0
 /**
  * Save product types.
  *
  * @return Xcom_Mapping_Model_Message_ProductTaxonomy_ProductType_Abstract_Response
  */
 public function process()
 {
     //since this process is delayed event prefix has to be set here
     $this->_eventPrefix = 'response_message';
     parent::process();
     $data = $this->getBody();
     if (isset($data['productTypes'])) {
         $this->saveProductTypes($data['productTypes']);
     }
     return $this;
 }
Example #9
0
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     try {
         $this->_processStartSale($data);
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return $this;
 }
Example #10
0
 /**
  * Process data on message received
  * @return array
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     $dataObject = array();
     $dataObject['destination_id'] = $this->getPublisherPseudonym();
     if (isset($data['payload'])) {
         $dataObject['payload'] = $data['payload'];
     }
     Mage::helper('xcom_xfabric')->send('message/pong', $dataObject);
     return $this;
 }
Example #11
0
 /**
  * Process data on message received
  * @return Xcom_Chronicle_Model_Message_Webstore_Provider_Get_Inbound
  */
 public function process()
 {
     parent::process();
     try {
         if ($this->_validateSchema()) {
             $providerName = Mage::getBaseUrl();
             $response = $this->_generateSuccessMessage($providerName);
             Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreMetadataProvision/GetAllWebStoreProviderSucceeded', $response);
         }
     } catch (Exception $ex) {
         //will just log the exception and just drop the request on the floor, because there is no
         //error message for this particular request
         Mage::logException($ex);
     }
     return $this;
 }
Example #12
0
 /**
  * Process message body and store result in database
  * @return Xcom_Mapping_Model_Message_ProductTaxonomy_Get_Succeeded
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     $localeCode = 'en_US';
     if (!is_null($data['locale'])) {
         $localeCode = $data['locale']['language'] . '_' . $data['locale']['country'];
     }
     $this->setLocaleCode($localeCode);
     $this->_deleteProductClasses($data);
     foreach ($data['productTaxonomy']['productClasses'] as $productClass) {
         $this->saveProductClass($productClass);
     }
     $this->setLoadedFlagConfig();
     return $this;
 }
Example #13
0
 /**
  * Process data on message received
  * @return Xcom_Chronicle_Model_Message_Order_Search_Inbound
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     try {
         $this->_processSearchQuery($data['ids']);
         if (count($this->_foundProducts) > 0) {
             $this->_sendFoundProducts();
         }
         if (count($this->_errors) > 0) {
             $this->_sendErrors();
         }
     } catch (Exception $e) {
         Mage::logException($e);
         $this->_notFoundProducts = $data['ids'];
         $this->_addSearchError($e->getMessage());
         $this->_sendErrors();
     }
     return $this;
 }
Example #14
0
 /**
  * Process data on message received
  * @return Xcom_Chronicle_Model_Message_Customer_Search_Inbound
  */
 public function process()
 {
     parent::process();
     $data = $this->getBody();
     if (!isset($data)) {
         $data = array();
     }
     if (!isset($data['modifiedSince'])) {
         $data['modifiedSince'] = null;
     }
     if (!isset($data['itemsRequested'])) {
         $data['itemsRequested'] = null;
     }
     if (!isset($data['startItemIndex'])) {
         $data['startItemIndex'] = null;
     }
     if (!isset($data['webStoreId'])) {
         $data['webStoreId'] = null;
     }
     try {
         if ($this->_validateSchema()) {
             $searchResults = $this->_processSearchQuery($data);
             $response = array('webStoreOffers' => $searchResults['results'], 'totalItemsFound' => $searchResults['totalItemsFound'], 'request' => array('webStoreId' => $data['webStoreId'], 'modifiedSince' => $data['modifiedSince'], 'itemsRequested' => $data['itemsRequested'], 'startItemIndex' => $data['startItemIndex']), 'destination_id' => $this->getPublisherPseudonym(), 'correlation_id' => $this->getCorrelationId());
             Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferSearch/SearchWebStoreOfferSucceeded', $response);
         }
     } catch (Xcom_Xfabric_Exception $ex) {
         Mage::logException($ex);
         $errorResponse = $this->_generate_failure_data($data['modifiedSince'], $data['itemsRequested'], $data['startItemIndex'], $data['webStoreId'], $ex, $ex->getCode());
         Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferSearch/SearchWebStoreOfferFailed', $errorResponse);
     } catch (Exception $ex) {
         if (!is_null($ex)) {
             $message = $ex->getMessage();
         }
         Mage::logException($ex);
         $errorResponse = $this->_generate_failure_data($data['modifiedSince'], $data['itemsRequested'], $data['startItemIndex'], $data['webStoreId'], $ex, $ex->getCode());
         Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreOfferSearch/SearchWebStoreOfferFailed', $errorResponse);
     }
     return $this;
 }
Example #15
0
 /**
  * Process data on message received
  * @return Xcom_Chronicle_Model_Message_Webstore_Get_Inbound
  */
 public function process()
 {
     parent::process();
     $providerName = Mage::getBaseUrl();
     try {
         if ($this->_validateSchema()) {
             $resultSet = $this->_processGetStores();
             if (!empty($resultSet['results'])) {
                 $response = $this->_generateSuccessMessage($providerName, $resultSet['results']);
                 Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreMetadataProvision/GetAllWebStoreSucceeded', $response);
             } else {
                 $response = $this->_generateFailureMessage($providerName, $resultSet['error']);
                 Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreMetadataProvision/GetAllWebStoreFailed', $response);
             }
         }
     } catch (Exception $ex) {
         Mage::logException($ex);
         $response = $this->_generateFailureMessage($providerName, $ex->getMessage());
         Mage::helper('xcom_xfabric')->send('com.x.webstore.v1/WebStoreMetadataProvision/GetAllWebStoreFailed', $response);
     }
     return $this;
 }
Example #16
0
 protected function _construct()
 {
     $this->_topic = 'productTaxonomy/getFailed';
     $this->_schemaRecordName = 'GetProductTaxonomyFailed';
     parent::_construct();
 }
Example #17
0
 /**
  * Initialization of class
  */
 protected function _construct()
 {
     parent::_construct();
     $this->_topic = 'message/pong';
 }
Example #18
0
 protected function _construct()
 {
     $this->_topic = 'productTaxonomy/productType/searchFailed';
     $this->_schemaRecordName = 'SearchProductTypeFailed';
     parent::_construct();
 }
Example #19
0
 /**
  * Initialization of class
  */
 protected function _construct()
 {
     parent::_construct();
     $this->_topic = 'productTaxonomy/updated';
 }