private function getItemDataByListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct) { $connectorClassName = 'Ess_M2ePro_Model_Connector_Server_' . ucfirst($listingProduct->getComponentMode()) . '_'; $connectorClassName .= $listingProduct->isComponentModeEbay() ? 'Item' : 'Product'; $connectorClassName .= '_Stop_Multiple'; try { $connector = new $connectorClassName(array(), array($listingProduct)); $itemData = $connector->getRequestDataPackage(); } catch (Exception $exception) { return NULL; } if (!isset($itemData['data']['items'])) { return NULL; } return array_shift($itemData['data']['items']); }
private function getItemDataByListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct) { $connectorClassName = 'Ess_M2ePro_Model_Connector_' . ucfirst($listingProduct->getComponentMode()) . '_'; $connectorClassName .= $listingProduct->isComponentModeEbay() ? 'Item' : 'Product'; $connectorClassName .= '_Stop_Multiple' . ($listingProduct->isComponentModeEbay() ? '' : 'Requester'); $connectorParams = array('logs_action_id' => 0, 'status_changer' => Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_UNKNOWN); try { $connector = new $connectorClassName($connectorParams, array($listingProduct)); $itemData = $connector->getRequestDataPackage(); } catch (Exception $exception) { return NULL; } if (!isset($itemData['data']['items'])) { return NULL; } return array_shift($itemData['data']['items']); }
private function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $action, $oldValue, $newValue, $messagePostfix = '') { // M2ePro_TRANSLATIONS // From [%from%] to [%to%]. $log = Mage::getModel('M2ePro/' . ucfirst($listingProduct->getComponentMode()) . '_Listing_Log'); $oldValue = strlen($oldValue) > 150 ? substr($oldValue, 0, 150) . ' ...' : $oldValue; $newValue = strlen($newValue) > 150 ? substr($newValue, 0, 150) . ' ...' : $newValue; $messagePostfix = trim(trim($messagePostfix), '.'); if (!empty($messagePostfix)) { $messagePostfix = ' ' . $messagePostfix; } if ($listingProduct->isComponentModeEbay() && is_array($listingProduct->getData('found_options_ids'))) { $collection = Mage::getModel('M2ePro/Listing_Product_Variation_Option')->getCollection()->addFieldToFilter('main_table.id', array('in' => $listingProduct->getData('found_options_ids'))); $additionalData = array(); foreach ($collection as $listingProductVariationOption) { /** @var Ess_M2ePro_Model_Listing_Product_Variation_Option $listingProductVariationOption */ $additionalData['variation_options'][$listingProductVariationOption->getAttribute()] = $listingProductVariationOption->getOption(); } if (!empty($additionalData['variation_options']) && $collection->getFirstItem()->getProductType() == Ess_M2ePro_Model_Magento_Product::TYPE_BUNDLE) { foreach ($additionalData['variation_options'] as $attribute => $option) { $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW, array('variation_options' => array($attribute => $option))); } return; } $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW, $additionalData); return; } $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
private function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $action, $oldValue, $newValue) { // M2ePro_TRANSLATIONS // From [%from%] to [%to%]. $log = Mage::getModel('M2ePro/Listing_Log'); $log->setComponentMode($listingProduct->getComponentMode()); $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%].', array('from' => $oldValue, 'to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }
private function logListingProductMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $action, $oldValue, $newValue, $messagePostfix = '') { // M2ePro_TRANSLATIONS // From [%from%] to [%to%]. if ($listingProduct->isComponentModeEbay()) { $log = Mage::getModel('M2ePro/Listing_Log'); $log->setComponentMode($listingProduct->getComponentMode()); } else { $log = Mage::getModel('M2ePro/' . ucfirst($listingProduct->getComponentMode()) . '_Listing_Log'); } $oldValue = strlen($oldValue) > 150 ? substr($oldValue, 0, 150) . ' ...' : $oldValue; $newValue = strlen($newValue) > 150 ? substr($newValue, 0, 150) . ' ...' : $newValue; $messagePostfix = trim(trim($messagePostfix), '.'); if (!empty($messagePostfix)) { $messagePostfix = ' ' . $messagePostfix; } $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION, NULL, $action, Mage::getModel('M2ePro/Log_Abstract')->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), Ess_M2ePro_Model_Log_Abstract::TYPE_NOTICE, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW); }