public function setUp() { parent::setUp(); $this->logger = $this->getHelperMockBuilder('ebayenterprise_magelog/data')->disableOriginalConstructor()->getMock(); $this->logContext = $this->getHelperMockBuilder('ebayenterprise_magelog/context')->disableOriginalConstructor()->getMock(); $this->logContext->expects($this->any())->method('getMetaData')->will($this->returnValue([])); }
/** * Extract tax data from the tax response payload and store tax records, * duties and fees. * * Extracts all three sets of tax data as each set of data can be retrieved * from the same address parser. Extracting all three sets at once prevents * nearly identical steps from being repeated for each ship group for each * type of tax data. * * @return self */ protected function _extractTaxData() { // Each of these will hold an array of arrays of data extracted from each // ship group - e.g. $taxRecords = [[$recordA, $recordB], [$recordC, $recordD]]. $taxRecords = []; $duties = []; $fees = []; foreach ($this->_taxResponse->getShipGroups() as $shipGroup) { $address = $this->_getQuoteAddressForShipGroup($shipGroup); if ($address) { $addressParser = $this->_taxFactory->createResponseAddressParser($shipGroup, $address); $taxRecords[] = $addressParser->getTaxRecords(); $duties[] = $addressParser->getTaxDuties(); $fees[] = $addressParser->getTaxFees(); } else { $this->_logger->warn('Tax response ship group does not relate to any known address.', $this->_logContext->getMetaData(__CLASS__, ['rom_response_body' => $shipGroup->serialize()])); } } // Flatten each nested array of tax data - allows for a single array_merge // instead of iteratively calling array_merge on each pass when extracting // tax data for each ship group. $this->_taxRecords = $this->_flattenArray($taxRecords); $this->_taxDuties = $this->_flattenArray($duties); $this->_taxFees = $this->_flattenArray($fees); return $this; }
protected function copyShipFromAddressTo(Mage_Customer_Model_Address_Abstract $address, EbayEnterprise_Inventory_Model_Details_Item $detail) { if ($detail->isAvailable()) { $meta = ['sku' => $detail->getSku(), 'item_id' => $detail->getItemId()]; $this->logger->debug('applying details for item "{sku}" [{item_id}]', $this->logContext->getMetaData(__CLASS__, $meta)); $address->addData($this->exportShipFromAddress($detail)); } }
/** * Before collecting item totals, check that all items * in the quote are available to be fulfilled. * * @param Varien_Event_Observer * @return self */ public function handleBeforeCollectTotals(Varien_Event_Observer $observer) { try { $quote = $observer->getEvent()->getQuote(); $this->quantityService->checkQuoteInventory($quote); } catch (EbayEnterprise_Inventory_Exception_Quantity_Collector_Exception $e) { $this->logger->warning($e->getMessage(), $this->logContext->getMetaData(__CLASS__, [], $e)); } return $this; }
/** * Lookup the tender type for given gift card. * @param string * @param string * @param bool * @return string * @throws EbayEnterprise_GiftCard_Exception_InvalidCardNumber_Exception If card number cannot be retrieved. */ public function lookupTenderType($cardNumber, $currencyCode, $panIsToken = false) { try { $api = $this->getTenderTypeLookupApi(); return $this->createTenderTypeLookup($cardNumber, $currencyCode, $api, $panIsToken)->getTenderType(); } catch (EbayEnterprise_GiftCard_Exception_TenderTypeLookupFailed_Exception $e) { $this->logger->error('Unable to lookup tender type', $this->logContext->getMetaData(__CLASS__, [], $e)); throw Mage::exception('EbayEnterprise_GiftCard_Exception_InvalidCardNumber', $this->helper->__(self::INVLIAD_CARD_NUMBER_MESSAGE, $cardNumber)); } }
/** * @param string $className * @param array $data * @param Exception $e * @param string $case the test case * @dataProvider providerGetMetaData * @loadFixture */ public function testGetMetaData($className, $data, $exception, $case) { $context = $this->_context->getMetaData($className, $data, $exception); if (!$exception) { $this->assertSame($this->expected($case)->getData(), $context); } else { $this->assertArrayHasKey('exception_class', $context); $this->assertArrayHasKey('exception_message', $context); $this->assertArrayHasKey('exception_stacktrace', $context); } }
public function setUp() { $this->helper = $this->getHelperMock('ebayenterprise_giftcard/data', ['__', 'getConfigData']); $this->coreHelper = $this->getHelperMock('eb2ccore/data', ['getSdkApi']); $this->logger = $this->getHelperMock('ebayenterprise_magelog/data'); $this->logContext = $this->getHelperMock('ebayenterprise_magelog/context'); $this->logContext->expects($this->any())->method('getMetaData')->will($this->returnValue([])); $this->apiLogger = $this->getMock('\\Psr\\Log\\NullLogger'); $this->config = $this->buildCoreConfigRegistry(['apiService' => 'payments', 'apiOperationTenderTypeLookup' => 'tendertype/lookup']); $this->constructorArgs = ['core_helper' => $this->coreHelper, 'helper' => $this->helper, 'logger' => $this->logger, 'log_context' => $this->logContext, 'api_logger' => $this->apiLogger, 'config' => $this->config]; }
/** * Make a request to the token validation service using the token set in * "magic" data. Should return the response message from the service. * @return string */ public function makeRequest() { // if there's no token, don't attempt to validate it if (!$this->getToken()) { $logMessage = 'No token to make request for'; $this->_logger->info($logMessage, $this->_context->getMetaData(__CLASS__)); return ''; } $response = Mage::getModel('eb2ccore/api')->setStatusHandlerPath(static::API_STATUS_HANDLER)->request($this->_buildRequest(), Mage::helper('eb2ccsr')->getConfigModel()->xsdFileTokenValidation, $this->_getApiUri()); return $response; }
/** * @link http://www.php.net/manual/en/class.exception.php */ public function __construct($message = "", $code = 0, Exception $previous = null) { $this->_logger = Mage::helper('ebayenterprise_magelog'); $this->_context = Mage::helper('ebayenterprise_magelog/context'); /** * @note This runs counter to our styleguide because it is * itself an exception. Furthermore we want to be both * inescapable and verbose with critical exceptions. */ $this->_logger->critical($message, $this->_context->getMetaData(__CLASS__, [], $previous)); parent::__construct($message, $code, $previous); }
/** * get the ROM identifier for the given magento shipping method code * return null if $shippingMethod evaluates to false * * @param string * @return string|null */ public function getMethodSdkId($shippingMethod) { $this->fetchAvailableShippingMethods(); if (!$shippingMethod) { return ''; } if (!isset($this->methods[$shippingMethod]['sdk_id'])) { $this->logger->error('Unable to get the SDK identifier for shipping method {shipping_method}', $this->logContext->getMetaData(__CLASS__, ['shipping_method' => $shippingMethod])); throw Mage::exception('EbayEnterprise_Eb2cCore', 'Unable to find a valid shipping method'); } return $this->methods[$shippingMethod]['sdk_id']; }
public function setUp() { parent::setUp(); $this->logger = $this->getHelperMockBuilder('ebayenterprise_magelog/data')->disableOriginalConstructor()->getMock(); $this->logContext = $this->getHelperMockBuilder('ebayenterprise_magelog/context')->disableOriginalConstructor()->getMock(); $this->logContext->expects($this->any())->method('getMetaData')->will($this->returnValue([])); $this->request = $this->getMockForAbstractClass('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IAllocationRollbackRequest'); $this->reply = $this->getMockForAbstractClass('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IAllocationRollbackReply'); $this->httpApi = $this->getMockBuilder('\\eBayEnterprise\\RetailOrderManagement\\Api\\IBidirectionalApi')->disableOriginalConstructor()->setMethods(['send', 'getRequestBody', 'getResponseBody', 'setRequestBody'])->getMock(); $this->httpApi->expects($this->any())->method('setRequestBody')->with($this->isInstanceOf('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IAllocationRollbackRequest'))->will($this->returnSelf()); $this->httpApi->expects($this->any())->method('getRequestBody')->will($this->returnValue($this->request)); $this->httpApi->expects($this->any())->method('getResponseBody')->will($this->returnValue($this->reply)); }
/** * Build the given batches into feed files. * @param array of EbayEnterprise_Catalog_Model_Pim_Batch $batches * @return self */ protected function _buildBatches(array $batches) { try { foreach ($batches as $batch) { Mage::getModel('ebayenterprise_catalog/pim', array('batch' => $batch))->buildFeed(); } $this->_updateCutoffDate(); } catch (EbayEnterprise_Eb2cCore_Exception_InvalidXml $e) { $logMessage = 'Error building export feeds'; $this->_logger->critical($logMessage, $this->_context->getMetaData(__CLASS__, [], $e)); } return $this; }
public function setUp() { parent::setUp(); // Prevent log context from needing session while gather context data for logging. $this->logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']); $this->logContext->method('getMetaData')->will($this->returnValue([])); $this->api = $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Api\\IBidirectionalApi'); $this->configModel = $this->buildCoreConfigRegistry(['apiService' => 'inventory', 'apiOperation' => 'allocate']); $this->helper = $this->getHelperMock('ebayenterprise_inventory'); $this->helper->method('getConfigModel')->will($this->returnValue($this->configModel)); $this->coreHelper = $this->getHelperMock('eb2ccore', ['getSdkApi']); $this->coreHelper->method('getSdkApi')->will($this->returnValue($this->api)); }
/** * @param Mage_Sales_Model_Order * @return self */ public function void(Mage_Sales_Model_Order $order) { if ($this->_canVoid($order)) { try { $this->_getVoidApi()->doVoidOrder($order); } catch (EbayEnterprise_PayPal_Exception $e) { $logMessage = 'Void request failed. See exception log for details.'; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__)); $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e)); } } return $this; }
/** * Get the last timestamp captured from a test message and return a new DateTime * object for the timestamp. If no last test message exists or is not a parseable * date time, will return null. * @return DateTime|null */ protected function _getLastTimestamp() { $lastTimestamp = $this->getValue(); $timestamp = null; try { // If the value isn't set, don't create a new DateTime. new DateTime(null) // gives a DateTime for the current time, which is not desirable here. $timestamp = $lastTimestamp ? $this->_coreHelper->getNewDateTime($lastTimestamp) : null; } catch (Exception $e) { $logData = ['last_timestamp' => $lastTimestamp]; $logMessage = 'Invalid timestamp for last AMQP test message timestamp: {last_timestamp}.'; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData, $e)); } return $timestamp; }
/** * attempt to do an inventory detail operation * * @param Mage_Sales_Model_Quote * @return EbayEnterprise_Inventory_Model_Details_Result */ protected function tryOperation(Mage_Sales_Model_Quote $quote) { $logger = $this->logger; $logContext = $this->logContext; try { $api = $this->prepareApi(); $request = $this->prepareRequest($api, $quote); if (count($request->getItems())) { $this->logger->debug('Trying inventory details operation', $this->logContext->getMetaData(__CLASS__)); $api->send(); } return $this->prepareResult($api); } catch (InvalidPayload $e) { $logger->warning('Invalid payload for inventory details. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } catch (NetworkError $e) { $logger->warning('Caught a network error sending the inventory details request. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } catch (UnsupportedOperation $e) { $logger->critical('The inventory details operation is unsupported in current configuration. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } catch (UnsupportedHttpAction $e) { $logger->critical('The inventory details operation is configured with an unsupported HTTP action. See exception log for more details.', $logContext->getMetaData(__CLASS__, ['exception_message' => $e->getMessage()])); $logger->logException($e, $logContext->getMetaData(__CLASS__, [], $e)); } // if we got here there was a problem throw Mage::exception('EbayEnterprise_Inventory_Exception_Details_Operation', 'Failed to fetch inventory details'); }
/** * Save an EAV collection, disabling the indexer if the collection is * larger than a configured size. * * @param Mage_Eav_Model_Entity_Collection_Abstract * @return self */ public function saveCollectionStubIndexer(Mage_Eav_Model_Entity_Collection_Abstract $collection) { $config = $this->getConfigModel(); $stubIndexer = $config->maxPartialReindexSkus < $collection->getSize(); if ($stubIndexer) { // Stub the indexer so no indexing can take place during massive saves. $indexerKey = '_singleton/index/indexer'; $oldIndexer = $this->reregister($indexerKey, $this->indexerStub); } $failureCount = 0; $logData = ['product_count' => $collection->getSize()]; $logMessage = 'Saving {product_count} products with stubbed indexer.'; $this->logger->info($logMessage, $this->context->getMetaData(__CLASS__, $logData)); $failMessage = 'Failed to save product with sku {sku}.'; foreach ($collection as $item) { try { $item->save(); } catch (Exception $e) { $failureCount++; $failLogData = ['sku' => $item->getSku(), 'exception' => $e]; $this->logger->logException($e, $this->context->getMetaData(__CLASS__, $failLogData))->error($failMessage, $this->context->getMetaData(__CLASS__, $failLogData)); } } $logMessage = 'Finished saving {product_count} products with {failure_count} failures.'; $logData['failure_count'] = $failureCount; $this->logger->info($logMessage, $this->context->getMetaData(__CLASS__, $logData)); if ($stubIndexer) { $this->reregister($indexerKey, $oldIndexer); } return $this; }
/** * Extract tax data from the ship group. * * Extracts all three sets of tax data as each set of data can be retrieved * from the same item parser. Extracting all three sets at once prevents * nearly identical steps from being repeated for each item for each type of * tax data. * * @return EbayEnterprise_Tax_Model_Record[] */ protected function _extractTaxData() { // Each of these will hold an array of arrays of data extracted from each // ship group - e.g. $taxRecords = [[$recordA, $recordB], [$recordC, $recordD]]. // Prepopulate tax records with data extracted for the address for gifting // so it will get merged together with item taxes. $taxRecords = [$this->_extractGiftingTaxRecords()]; $duties = []; $fees = []; /** @var ITaxedOrderItem $orderItem */ foreach ($this->_shipGroup->getItems() as $orderItem) { /** @var Mage_Sales_Model_Quote_Item $item */ $item = $this->_getItemForItemPayload($orderItem); if ($item) { $itemParser = $this->_taxFactory->createResponseItemParser($orderItem, $item, $this->_addressId, $this->_quoteId); $taxRecords[] = $itemParser->getTaxRecords(); $duties[] = $itemParser->getTaxDuties(); $fees[] = $itemParser->getTaxFees(); } else { $this->_logger->warning('Tax response item does not relate to any known quote item.', $this->_logContext->getMetaData(__CLASS__, ['rom_response_body' => $orderItem->serialize()])); } } // Flatten each nested array of tax data - allows for a single array_merge // instead of iteratively calling array_merge on each pass when extracting // tax data for each item. $this->_taxRecords = $this->_flattenArray($taxRecords); $this->_taxDuties = $this->_flattenArray($duties); $this->_taxFees = $this->_flattenArray($fees); return $this; }
/** * Process all of the products within a given store. * * @param Mage_Catalog_Model_Resource_Product_Collection $products products for a specific store * @param EbayEnterprise_Catalog_Model_Pim_Product_Collection $pimProducts collection of PIM Product instances * @param string $key * @param array $productIds * @return EbayEnterprise_Catalog_Model_Pim_Product_Collection $pimProducts collection of PIM Product instances */ protected function _processProductCollection(Mage_Catalog_Model_Resource_Product_Collection $products, EbayEnterprise_Catalog_Model_Pim_Product_Collection $pimProducts, array &$productIds = null) { $excludedProductIds = array(); $currentStoreId = $products->getStoreId(); $config = Mage::helper('eb2ccore')->getConfigModel($currentStoreId); $clientId = $config->clientId; $catalogId = $config->catalogId; foreach ($products->getItems() as $product) { $product->setStoreId($currentStoreId); $pimProduct = $pimProducts->getItemForProduct($product); if (!$pimProduct) { $pimProduct = Mage::getModel('ebayenterprise_catalog/pim_product', array('client_id' => $clientId, 'catalog_id' => $catalogId, 'sku' => $product->getSku())); $pimProducts->addItem($pimProduct); } try { $pimProduct->loadPimAttributesByProduct($product, $this->_doc, $this->_getFeedConfig(), $this->_getFeedAttributes($currentStoreId)); } catch (EbayEnterprise_Catalog_Model_Pim_Product_Validation_Exception $e) { $logData = ['sku' => $pimProduct->getSku()]; $logMessage = 'Product "{sku}" excluded from export.'; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData)); $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e)); $excludedProductIds[] = $product->getId(); $pimProducts->deleteItem($pimProduct); } } if ($productIds) { $productIds = array_diff($productIds, $excludedProductIds); } return $pimProducts; }
/** * Update session data with a new quote object. Method should get a diff of the * current/old quote data and diff it with the new quote data. This data should * then be used to update flags as needed. Finally, the new data should replace * existing data. * @param Mage_Sales_Model_Quote $quote New quote object * @return self */ public function updateWithQuote(Mage_Sales_Model_Quote $quote) { $oldData = $this->getCurrentQuoteData(); $newData = $this->_extractQuoteData($quote); // Copy over the last_updated timestamp from the old quote data. This will // persist the timestamp from one set of data to the next preventing // the new data from auto expiring. $newData['last_updated'] = $oldData['last_updated']; $this->_logger->debug('Comparing quote data', $this->_context->getMetaData(__CLASS__, ['old' => json_encode($oldData), 'new' => json_encode($newData)])); $quoteDiff = $this->_diffQuoteData($oldData, $newData); // if nothing has changed in the quote, no need to update flags, or // quote data as none of them will change if (!empty($quoteDiff)) { $changes = implode(', ', array_keys($quoteDiff)); $logData = ['changes' => $changes, 'diff' => json_encode($quoteDiff)]; $logMessage = 'Changes found in quote for: {changes}'; $this->_logger->debug($logMessage, $this->_context->getMetaData(__CLASS__, $logData)); $this->setTaxUpdateRequiredFlag($this->_changeRequiresTaxUpdate($newData, $quoteDiff))->setDetailsUpdateRequiredFlag($this->_changeRequiresDetailsUpdate($newData, $quoteDiff))->setCurrentQuoteData($newData); } else { $this->_logger->debug('No changes in quote.', $this->_context->getMetaData(__CLASS__)); } // always update the changes - could go from having changes to no changes $this->setQuoteChanges($quoteDiff); return $this; }
/** * prepare stubs */ public function setUp() { parent::setUp(); $this->_httpApi = $this->getMockBuilder('\\eBayEnterprise\\RetailOrderManagement\\Api\\HttpApi')->disableOriginalConstructor()->getMock(); $this->_observerStub = $this->getModelMock('ebayenterprise_order/observer'); $this->_itemSelection = $this->getHelperMock('ebayenterprise_order/item_selection', ['selectFrom']); $this->_payloadFactory = new PayloadFactory(); $this->_request = $this->_payloadFactory->buildPayload('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\OrderCreateRequest'); $this->_requestStub = $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\IOrderCreateRequest'); $this->_replyStub = $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Order\\IOrderCreateReply'); $this->_coreHelperStub = $this->getHelperMock('eb2ccore/data', ['generateRequestId', 'getConfigModel']); $coreConfig = $this->buildCoreConfigRegistry(['clientCustomerIdPrefix' => $this->_clientCustomerIdPrefix, 'language_code' => 'en-us', 'clientCustomerIdLength' => 0]); $this->_coreHelperStub->expects($this->any())->method('getConfigModel')->will($this->returnValue($coreConfig)); $this->_config = $this->buildCoreConfigRegistry(['levelOfService' => $this->_expectedLevelOfService, 'orderType' => $this->_expectedOrderType, 'requestIdPrefix' => $this->_expectedRequestIdPrefix, 'apiCreateOperation' => 'create', 'apiService' => 'orders', 'genderMap' => ['Female' => 'F', 'Male' => 'M', 'SomeOtherGender' => 'Invalid']]); $this->_orderHelperStub = $this->getHelperMock('ebayenterprise_order', ['prefixCustomerId']); // Mock the customer id prefixing method to return the customer id // prefixed with the constant client customer id prefix. $clientCustomerIdPrefix = $this->_clientCustomerIdPrefix; $this->_orderHelperStub->method('prefixCustomerId')->will($this->returnCallback(function ($id) use($clientCustomerIdPrefix) { return $clientCustomerIdPrefix . $id; })); $this->_customer = Mage::getModel('customer/customer', ['increment_id' => '12345123456789']); $this->_order = Mage::getModel('sales/order', ['created_at' => '2014-07-28 16:22:46', 'customer' => $this->_customer, 'customer_dob' => '2014-07-28 16:22:46', 'customer_email' => '*****@*****.**', 'customer_firstname' => 'fname', 'customer_lastname' => 'lname', 'customer_middlename' => 'mname', 'customer_prefix' => 'mr', 'customer_id' => '123456789', 'customer_taxvat' => 'taxid', 'increment_id' => '12345123456789']); $this->_item1 = $this->getModelMock('sales/order_item', []); $this->_item2 = $this->getModelMock('sales/order_item', []); $this->_billAddress = Mage::getModel('sales/order_address', ['address_type' => Mage_Customer_Model_Address_Abstract::TYPE_BILLING, 'entity_id' => $this->_billAddressId]); $this->_shipAddress = Mage::getModel('sales/order_address', ['address_type' => Mage_Customer_Model_Address_Abstract::TYPE_SHIPPING, 'entity_id' => $this->_shipAddressId]); // Mock log context to prevent session interactions while building out log data. $this->_logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']); $this->_logContext->method('getMetaData')->will($this->returnValue([])); // prevent magento events from actually triggering Mage::app()->disableEvents(); }
/** * Return an instance of `sales/order` when the payload have a valid customer increment id, * the order increment id correspond to a sales order in the Magento store, and the order in the Magento * store is shippable. However, if any of these conditions are not met a null value will be returned. * @return Mage_Sales_Model_Order | null */ protected function _getOrder() { $incrementId = $this->_payload->getCustomerOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); if (!$order->getId()) { $logMsgOrderNotFound = "The shipment could not be added. The order (id: {$incrementId}) was not found in this Magento store."; $this->_logger->warning($logMsgOrderNotFound, $this->_context->getMetaData(__CLASS__)); return null; } if (!$order->canShip()) { $logMsgOrderNotShippable = "Order ({$incrementId}) can not be shipped."; $this->_logger->warning($logMsgOrderNotShippable, $this->_context->getMetaData(__CLASS__)); return null; } return $order; }
/** * attempt to undo an allocation * * @param EbayEnterprise_Inventory_Model_Allocation_Reservation */ public function rollback(EbayEnterprise_Inventory_Model_Allocation_Reservation $reservation) { $api = $this->prepareApi(); try { $this->prepareRequest($api, $reservation); $api->send(); return; } catch (InvalidPayload $e) { $this->logger->warning('The allocation rollback response payload is invalid.', $this->logContext->getMetaData(__CLASS__, [], $e)); } catch (NetworkError $e) { $this->logger->warning('Failed sending the allocation rollback request.', $this->logContext->getMetaData(__CLASS__, [], $e)); } catch (UnsupportedOperation $e) { $this->logger->critical('Allocation rollback is unsupported in the currently configured SDK.', $this->logContext->getMetaData(__CLASS__, [], $e)); } catch (UnsupportedHttpAction $e) { $this->logger->critical('Allocation rollback configured to use unsupported HTTP action.', $this->logContext->getMetaData(__CLASS__, [], $e)); } }
public function setUp() { parent::setUp(); $this->logger = $this->getHelperMockBuilder('ebayenterprise_magelog/data')->disableOriginalConstructor()->getMock(); $this->logContext = $this->getHelperMockBuilder('ebayenterprise_magelog/context')->disableOriginalConstructor()->getMock(); $this->logContext->expects($this->any())->method('getMetaData')->will($this->returnValue([])); // mock the item iterable to create and store // item payloads $this->itemIterable = $this->getMockBuilder('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IItemIterable')->disableOriginalConstructor()->setMethods(['attach', 'getEmptyShippingItem', 'getEmptyInStorePickUpItem'])->getMockForAbstractClass(); // mock the request to return the iterable mock $this->request = $this->getMockBuilder('\\eBayEnterprise\\RetailOrderManagement\\Payload\\Inventory\\IInventoryDetailsRequest')->disableOriginalConstructor()->setMethods(['getItems'])->getMockForAbstractClass(); $this->request->expects($this->any())->method('getItems')->will($this->returnValue($this->itemIterable)); // avoid having to mock the item helper's dependencies $this->itemHelper = $this->getHelperMock('ebayenterprise_inventory/details_item', ['fillOutShippingItem']); // prevent magento events from actually triggering Mage::app()->disableEvents(); }
/** * Dispacth an event in Magento with the payload and store scope it was received in. * @param IOrderEvent $payload * @param Mage_Core_Model_Store $store * @return self */ protected function _dispatchPayload(IOrderEvent $payload, Mage_Core_Model_Store $store) { $eventName = $this->_eventPrefix . '_' . $this->_coreHelper->underscoreWords($payload->getEventType()); $logData = ['event_name' => $eventName]; $logMessage = 'Dispatching event "{event_name}" for payload.'; $this->_logger->info($logMessage, $this->_context->getMetaData(__CLASS__, $logData)); Mage::dispatchEvent($eventName, array('payload' => $payload, 'store' => $store)); return $this; }
/** * add the shipping method to the the list if it is a * valid ROM shipping method * * @param string * @param string */ protected function storeShippingMethodInfo($shippingMethod, $displayString) { $sdkId = $this->lookupShipMethod($shippingMethod); if (!$sdkId) { $this->logger->warning('Encountered active shipping method with no ROM mapping.', $this->logContext->getMetaData(__CLASS__, ['shipping_method' => $shippingMethod, 'display_string' => $displayString])); return; } $this->methods[$shippingMethod] = ['sdk_id' => $sdkId, 'display_text' => $displayString]; }
/** * get meta data used when emitting a warning for the result code * @param string * @return array */ protected function getMetaData($resultCode) { if ($resultCode === IValidationReply::RESULT_UNABLE_TO_CONTACT_PROVIDER || $resultCode === IValidationReply::RESULT_TIMEOUT || $resultCode === IValidationReply::RESULT_MALFORMED || $resultCode === IValidationReply::RESULT_PROVIDER_ERROR) { $logData = []; } else { $logData = ['result_code' => $this->getResultCode()]; } return $this->context->getMetaData(__CLASS__, $logData); }
/** * Redeem the gift card for the requested amount and return the amount that * was actually redeemed for the card. * @param EbayEnterprise_GiftCard_Model_IGiftcard $card * @param float $amount * @return self */ protected function _redeemVoidCard(EbayEnterprise_GiftCard_Model_IGiftcard $card) { try { $card->void(); } catch (EbayEnterprise_GiftCard_Exception $e) { $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e)); } return $card; }
/** * Verify that the passed in track number is in the collections of Magento shipment tracks, otherwise logs warning message. * @param Varien_Data_Collection $tracks * @param OrderEvents\ITrackingNumber $trackingNumber * @return self */ protected function _verifyTrack(Varien_Data_Collection $tracks, OrderEvents\ITrackingNumber $trackingNumber) { $number = $trackingNumber->getTrackingNumber(); $track = $tracks->getItemByColumnValue('track_number', $number); if (is_null($track)) { $logMessage = "Magento did not add an expected-to-be-shipped Track number ({$number}) to the shipment."; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__)); } return $this; }
/** * Sets configurable_attributes_data * @param string $productTypeId ('configurable', 'simple' etc). * @param Varien_Object $source the source data field * @param Mage_Catalog_Model_Product $product the product we are setting * @return array of configurable_attributes_data */ public function getConfigurableAttributesData($productTypeId, Varien_Object $source, Mage_Catalog_Model_Product $product) { if ($product->getId() && $product->getTypeId() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $productTypeId === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE && $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product)) { $logData = ['sku' => $product->getSku()]; $logMessage = 'Cannot change existing configurable attributes; update discarded for SKU "{sku}"'; $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData)); return null; } return $source->getData('configurable_attributes_data'); }