Exemple #1
0
 private function getItemDataByListingProduct(\Ess\M2ePro\Model\Listing\Product $listingProduct)
 {
     $connectorName = ucfirst($listingProduct->getComponentMode()) . '\\Connector\\';
     $connectorName .= $listingProduct->isComponentModeEbay() ? 'Item' : 'Product';
     $connectorName .= '\\Stop\\MultipleRequester';
     $connectorParams = array('logs_action_id' => 0, 'status_changer' => \Ess\M2ePro\Model\Listing\Product::STATUS_CHANGER_UNKNOWN);
     try {
         $dispatcher = $this->modelFactory->getObject(ucfirst($listingProduct->getComponentMode()) . '_Connector\\Dispatcher');
         $connector = $dispatcher->getCustomConnector($connectorName, $connectorParams);
         $connector->setListingsProducts(array($listingProduct));
         $itemData = $connector->getRequestDataPackage();
     } catch (\Exception $exception) {
         return NULL;
     }
     if (!isset($itemData['data']['items'])) {
         return NULL;
     }
     return array_shift($itemData['data']['items']);
 }
Exemple #2
0
 private function logListingProductMessage(\Ess\M2ePro\Model\Listing\Product $listingProduct, $action, $oldValue, $newValue)
 {
     // M2ePro\TRANSLATIONS
     // From [%from%] to [%to%].
     $log = $this->activeRecordFactory->getObject('Listing\\Log');
     $log->setComponentMode($listingProduct->getComponentMode());
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, NULL, $action, $log->encodeDescription('From [%from%] to [%to%].', array('from' => $oldValue, 'to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }
Exemple #3
0
 private function logListingProductMessage(\Ess\M2ePro\Model\Listing\Product $listingProduct, $action, $oldValue, $newValue, $messagePostfix = '')
 {
     // M2ePro\TRANSLATIONS
     // From [%from%] to [%to%].
     $log = $this->activeRecordFactory->getObject(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 = $this->activeRecordFactory->getObject('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, $log->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::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, $log->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW, $additionalData);
         return;
     }
     $log->addProductMessage($listingProduct->getListingId(), $listingProduct->getProductId(), $listingProduct->getId(), \Ess\M2ePro\Helper\Data::INITIATOR_EXTENSION, NULL, $action, $log->encodeDescription('From [%from%] to [%to%]' . $messagePostfix . '.', array('!from' => $oldValue, '!to' => $newValue)), \Ess\M2ePro\Model\Log\AbstractLog::TYPE_NOTICE, \Ess\M2ePro\Model\Log\AbstractLog::PRIORITY_LOW);
 }