Ejemplo n.º 1
0
 public function runManual(Ess_M2ePro_Model_Listing_Product $listingProduct, $query, Ess_M2ePro_Model_Marketplace $marketplace = NULL, Ess_M2ePro_Model_Account $account = NULL)
 {
     if (!$listingProduct->isNotListed() || empty($query)) {
         return false;
     }
     $params = array('listing_product' => $listingProduct, 'query' => $query);
     if (is_null($marketplace)) {
         $marketplace = $listingProduct->getListing()->getMarketplace();
     }
     if (is_null($account)) {
         $account = $listingProduct->getListing()->getAccount();
     }
     try {
         $dispatcherObject = Mage::getModel('M2ePro/Connector_Server_Amazon_Dispatcher');
         $dispatcherObject->processConnector('search', 'manual', 'requester', $params, $marketplace, $account, 'Ess_M2ePro_Model_Amazon');
     } catch (Exception $exception) {
         Mage::helper('M2ePro/Module_Exception')->process($exception);
         return false;
     }
     $result = Mage::helper('M2ePro/Data_Global')->getValue('temp_amazon_manual_search_asin_result');
     Mage::helper('M2ePro/Data_Global')->unsetValue('temp_amazon_manual_search_asin_result');
     if (!is_array($result)) {
         return array();
     }
     return $result;
 }
Ejemplo n.º 2
0
 public function setLocks($hash)
 {
     $this->listingProduct->addObjectLock(NULL, $hash);
     $this->listingProduct->addObjectLock('in_action', $hash);
     $this->listingProduct->addObjectLock('search_action', $hash);
     $this->listingProduct->getListing()->addObjectLock(NULL, $hash);
     $this->listingProduct->getListing()->addObjectLock('products_in_action', $hash);
     $this->listingProduct->getListing()->addObjectLock('products_search_action', $hash);
     $this->account->addObjectLock('products_in_action', $hash);
     $this->account->addObjectLock('products_search_action', $hash);
     $this->marketplace->addObjectLock('products_in_action', $hash);
     $this->marketplace->addObjectLock('products_search_action', $hash);
     $processingStatus = Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_PROCESSING;
     $this->listingProduct->getChildObject()->setData('general_id_search_status', $processingStatus)->save();
 }
Ejemplo n.º 3
0
 private function getQueryParam(Ess_M2ePro_Model_Listing_Product $listingProduct, $step)
 {
     $validation = Mage::helper('M2ePro');
     switch ($step) {
         case self::STEP_ASIN_ISBN:
             $query = $listingProduct->getChildObject()->getGeneralId();
             empty($query) && ($query = $listingProduct->getChildObject()->getAddingGeneralId());
             if (!Mage::helper('M2ePro/Component_Amazon')->isASIN($query) && !$validation->isISBN($query)) {
                 $query = false;
             }
             break;
         case self::STEP_UPC_EAN:
             $query = $listingProduct->getChildObject()->getWorldwideId();
             empty($query) && ($query = $listingProduct->getChildObject()->getAddingWorldwideId());
             if (!$validation->isEAN($query) && !$validation->isUPC($query)) {
                 $query = false;
             }
             break;
         case self::STEP_MAGENTO_TITLE:
             $query = false;
             if ($listingProduct->getListing()->getChildObject()->isSearchByMagentoTitleModeEnabled()) {
                 $query = $listingProduct->getChildObject()->getActualMagentoProduct()->getName();
             }
             break;
         default:
             throw new Exception('Step is out of knowledge base.');
     }
     return $query;
 }
Ejemplo n.º 4
0
 private function getSearchType()
 {
     /* @var $listing Ess_M2ePro_Model_Buy_Listing */
     $listing = $this->listingProduct->getListing()->getChildObject();
     $searchType = false;
     if ($listing->isGeneralIdGeneralIdMode()) {
         $searchType = 'sku';
     }
     return $searchType;
 }
Ejemplo n.º 5
0
 private function getSearchMethod(Ess_M2ePro_Model_Listing_Product $listingProduct, $step)
 {
     /** @var $listing Ess_M2ePro_Model_Play_Listing */
     $listing = $listingProduct->getListing()->getChildObject();
     if ($step == self::STEP_GENERAL_ID) {
         if ($listing->isGeneralIdWorldwideMode() || $listing->isGeneralIdIsbnMode()) {
             return 'byEanIsbn';
         }
     }
     return 'byQuery';
 }
Ejemplo n.º 6
0
 private function getSearchType()
 {
     /* @var $listing Ess_M2ePro_Model_Buy_Listing */
     $listing = $this->listingProduct->getListing()->getChildObject();
     $searchType = false;
     if ($listing->isGeneralIdGeneralIdMode()) {
         $searchType = Ess_M2ePro_Model_Connector_Buy_Search_ByIdentifier_ItemsRequester::SEARCH_TYPE_GENERAL_ID;
     }
     if ($listing->isGeneralIdWorldwideMode()) {
         $searchType = Ess_M2ePro_Model_Connector_Buy_Search_ByIdentifier_ItemsRequester::SEARCH_TYPE_UPC;
     }
     return $searchType;
 }
Ejemplo n.º 7
0
 public function getRequestData()
 {
     /** @var $listing Ess_M2ePro_Model_Buy_Listing */
     $listing = $this->listingProduct->getListing()->getChildObject();
     $searchType = false;
     if ($listing->isGeneralIdGeneralIdMode()) {
         $searchType = Ess_M2ePro_Model_Connector_Server_Buy_Search_Items::SEARCH_TYPE_GENERAL_ID;
     }
     if ($listing->isGeneralIdWorldwideMode()) {
         $searchType = Ess_M2ePro_Model_Connector_Server_Buy_Search_Items::SEARCH_TYPE_UPC;
     }
     return $searchType ? array('search_type' => $searchType) : array();
 }
Ejemplo n.º 8
0
 public function unsetLocks($hash, $fail = false, $message = NULL)
 {
     if (!$this->unsetProcessingLock) {
         return;
     }
     $this->listingProduct->deleteObjectLocks(NULL, $hash);
     $this->listingProduct->deleteObjectLocks('in_action', $hash);
     $this->listingProduct->deleteObjectLocks('search_action', $hash);
     $this->listingProduct->getListing()->deleteObjectLocks(NULL, $hash);
     $this->listingProduct->getListing()->deleteObjectLocks('products_in_action', $hash);
     $this->listingProduct->getListing()->deleteObjectLocks('products_search_action', $hash);
     $this->getAccount()->deleteObjectLocks('products_in_action', $hash);
     $this->getAccount()->deleteObjectLocks('products_search_action', $hash);
     $this->getMarketplace()->deleteObjectLocks('products_in_action', $hash);
     $this->getMarketplace()->deleteObjectLocks('products_search_action', $hash);
     $processingStatus = Ess_M2ePro_Model_Amazon_Listing_Product::GENERAL_ID_SEARCH_STATUS_NONE;
     $this->listingProduct->getChildObject()->setData('general_id_search_status', $processingStatus)->save();
     if ($fail) {
         $logModel = Mage::getModel('M2ePro/Listing_Log');
         $logModel->setComponentMode(Ess_M2ePro_Helper_Component_Amazon::NICK);
         $logModel->addListingMessage($this->listingProduct->getListingId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_UNKNOWN, NULL, Ess_M2ePro_Model_Listing_Log::ACTION_UNKNOWN, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_ERROR, Ess_M2ePro_Model_Log_Abstract::PRIORITY_HIGH);
     }
 }
Ejemplo n.º 9
0
 private function calculateCurrentData()
 {
     if (!empty($this->currentQuery) || $this->currentStep > self::STEP_MAGENTO_TITLE) {
         return;
     }
     switch ($this->currentStep) {
         case self::STEP_UPC_EAN:
             $tempQuery = $this->listingProduct->getChildObject()->getWorldwideId();
             empty($tempQuery) && ($tempQuery = $this->listingProduct->getChildObject()->getAddingWorldwideId());
             !empty($tempQuery) && ($this->currentStep = self::STEP_UPC_EAN);
             !empty($tempQuery) && ($this->currentQuery = (string) $tempQuery);
             break;
         case self::STEP_MAGENTO_TITLE:
             $tempQuery = '';
             if ($this->listingProduct->getListing()->getChildObject()->isSearchByMagentoTitleModeEnabled()) {
                 $tempQuery = $this->listingProduct->getChildObject()->getActualMagentoProduct()->getName();
             }
             !empty($tempQuery) && ($this->currentStep = self::STEP_MAGENTO_TITLE);
             !empty($tempQuery) && ($this->currentQuery = (string) $tempQuery);
             break;
     }
     empty($this->currentQuery) && $this->currentStep++;
     $this->calculateCurrentData();
 }
Ejemplo n.º 10
0
 public function getRequestData(Ess_M2ePro_Model_Listing_Product $listingProduct, array &$requestData)
 {
     $requestData['shipping'] = array();
     /** @var $shippingTemplate Ess_M2ePro_Model_Ebay_Template_Shipping */
     $shippingTemplate = $listingProduct->getChildObject()->getShippingTemplate();
     $shippingTemplate->setMagentoProduct($listingProduct->getMagentoProduct());
     $accountId = $listingProduct->getListing()->getAccountId();
     $this->addLocalShippingData($shippingTemplate, $accountId, $requestData);
     $this->addInternationalShippingData($shippingTemplate, $accountId, $requestData);
     $this->addGlobalShippingProgramData($shippingTemplate, $requestData);
     $this->addExcludedLocationsData($shippingTemplate, $requestData);
     if ($shippingTemplate->isLocalShippingFlatEnabled() && $shippingTemplate->isLocalShippingRateTableEnabled() && !$shippingTemplate->isInternationalShippingCalculatedEnabled() && !isset($requestData['shipping']['calculated'])) {
         $calculatedData = $this->getCalculatedData($shippingTemplate, $listingProduct);
         unset($calculatedData['package_size']);
         unset($calculatedData['originating_postal_code']);
         unset($calculatedData['dimensions']);
         $requestData['shipping']['calculated'] = $calculatedData;
     }
     $this->addAdditionalData($shippingTemplate, $requestData);
     $this->addLocationData($shippingTemplate, $requestData);
     $this->addInternationalTradeData($shippingTemplate, $requestData);
 }
Ejemplo n.º 11
0
 private function linkItem(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $data = array('general_id' => $listingProduct->getData('general_id'), 'sku' => $listingProduct->getData('sku'), 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
     $listingProduct->addData($data)->save();
     $dataForAdd = array('account_id' => $listingProduct->getListing()->getAccountId(), 'marketplace_id' => $listingProduct->getListing()->getMarketplaceId(), 'sku' => $listingProduct->getData('sku'), 'product_id' => $listingProduct->getProductId(), 'store_id' => $listingProduct->getListing()->getStoreId());
     if ($listingProduct->getChildObject()->isVariationsReady()) {
         $variations = $listingProduct->getVariations(true);
         /* @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $variation = reset($variations);
         $options = $variation->getOptions();
         $dataForAdd['variation_options'] = array();
         foreach ($options as $optionData) {
             $dataForAdd['variation_options'][$optionData['attribute']] = $optionData['option'];
         }
         $dataForAdd['variation_options'] = json_encode($dataForAdd['variation_options']);
     }
     Mage::getModel('M2ePro/Buy_Item')->setData($dataForAdd)->save();
     $message = Mage::helper('M2ePro')->__('The product was found in your Rakuten.com inventory and linked by Reference ID.');
     $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
 }
Ejemplo n.º 12
0
 protected function processAddedListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, array $params)
 {
     if (empty($params['template_description_id'])) {
         return;
     }
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     if (!$amazonListingProduct->getVariationManager()->isRelationParentType()) {
         $listingProduct->setData('template_description_id', $params['template_description_id']);
         $listingProduct->setData('is_general_id_owner', Ess_M2ePro_Model_Amazon_Listing_Product::IS_GENERAL_ID_OWNER_YES);
         $listingProduct->save();
         return;
     }
     $processor = $amazonListingProduct->getVariationManager()->getTypeModel()->getProcessor();
     if ($listingProduct->getMagentoProduct()->isBundleType() || $listingProduct->getMagentoProduct()->isSimpleTypeWithCustomOptions()) {
         $processor->process();
         return;
     }
     $detailsModel = Mage::getModel('M2ePro/Amazon_Marketplace_Details');
     $detailsModel->setMarketplaceId($listingProduct->getListing()->getMarketplaceId());
     /** @var Ess_M2ePro_Model_Template_Description $descriptionTemplate */
     $descriptionTemplate = Mage::helper('M2ePro/Component_Amazon')->getModel('Template_Description')->load($params['template_description_id']);
     /** @var Ess_M2ePro_Model_Amazon_Template_Description $amazonDescriptionTemplate */
     $amazonDescriptionTemplate = $descriptionTemplate->getChildObject();
     $possibleThemes = $detailsModel->getVariationThemes($amazonDescriptionTemplate->getProductDataNick());
     $productAttributes = $amazonListingProduct->getVariationManager()->getTypeModel()->getProductAttributes();
     foreach ($possibleThemes as $theme) {
         if (count($theme['attributes']) != count($productAttributes)) {
             continue;
         }
         $listingProduct->setData('template_description_id', $params['template_description_id']);
         $listingProduct->setData('is_general_id_owner', Ess_M2ePro_Model_Amazon_Listing_Product::IS_GENERAL_ID_OWNER_YES);
         break;
     }
     $listingProduct->save();
     $processor->process();
 }
Ejemplo n.º 13
0
 private function linkItem(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $data = array('general_id' => $listingProduct->getData('general_id'), 'is_isbn_general_id' => Mage::helper('M2ePro')->isISBN($listingProduct->getData('general_id')), 'sku' => $listingProduct->getData('sku'), 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
     $listingProduct->addData($data)->save();
     $dataForAdd = array('account_id' => $listingProduct->getListing()->getAccountId(), 'marketplace_id' => $listingProduct->getListing()->getMarketplaceId(), 'sku' => $listingProduct->getData('sku'), 'product_id' => $listingProduct->getProductId(), 'store_id' => $listingProduct->getListing()->getStoreId());
     Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save();
     $message = Mage::helper('M2ePro')->__('The product was found in your Amazon inventory and linked by SKU.');
     $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
 }
Ejemplo n.º 14
0
 public function addNotFoundAttributesMessage(Ess_M2ePro_Model_Listing_Product $listingProduct, $optionTitle, array $attributesCodes)
 {
     $attributesTitles = array();
     foreach ($attributesCodes as $attributeCode) {
         $attributesTitles[] = Mage::helper('M2ePro/Magento_Attribute')->getAttributeLabel($attributeCode, $listingProduct->getListing()->getStoreId());
     }
     $message = Mage::helper('M2ePro')->__('%s: attribute(s) %s were not found in this product and its value was not sent.', $optionTitle, implode(',', $attributesTitles));
     $listingProduct->addAdditionalWarningMessage($message);
 }
Ejemplo n.º 15
0
 /**
  * @param Ess_M2ePro_Model_Listing_Product $listingProduct
  * @return bool
  * @throws Ess_M2ePro_Model_Exception_Logic
  */
 public function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     if (!$listingProduct->isListed()) {
         return false;
     }
     if (!$listingProduct->isStoppable() || $listingProduct->isHidden()) {
         return false;
     }
     /** @var Ess_M2ePro_Model_Ebay_Listing_Product $ebayListingProduct */
     $ebayListingProduct = $listingProduct->getChildObject();
     $ebaySynchronizationTemplate = $ebayListingProduct->getEbaySynchronizationTemplate();
     if (!$ebayListingProduct->isSetCategoryTemplate()) {
         return false;
     }
     $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation');
     if ($ebaySynchronizationTemplate->isStopStatusDisabled()) {
         if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) {
             return true;
         } else {
             if ($ebayListingProduct->isVariationsReady()) {
                 $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isStopOutOfStock()) {
         if (!$listingProduct->getMagentoProduct()->isStockAvailability()) {
             return true;
         } else {
             if ($ebayListingProduct->isVariationsReady()) {
                 $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($ebaySynchronizationTemplate->isStopWhenQtyMagentoHasValue()) {
         $productQty = (int) $listingProduct->getMagentoProduct()->getQty(true);
         $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyMagentoHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     if ($ebaySynchronizationTemplate->isStopWhenQtyCalculatedHasValue()) {
         $productQty = (int) $ebayListingProduct->getQty();
         $typeQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueType();
         $minQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueMin();
         $maxQty = (int) $ebaySynchronizationTemplate->getStopWhenQtyCalculatedHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Ebay_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 16
0
 protected function createNewAmazonItem(Ess_M2ePro_Model_Listing_Product $listingProduct, $sku)
 {
     $dataForAdd = array('account_id' => (int) $listingProduct->getListing()->getGeneralTemplate()->getAccountId(), 'marketplace_id' => (int) $listingProduct->getListing()->getGeneralTemplate()->getMarketplaceId(), 'sku' => $sku, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
     return Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save()->getId();
 }
Ejemplo n.º 17
0
 public function getImagesData(Ess_M2ePro_Model_Listing_Product $listingProduct, array $params = array())
 {
     if (!$listingProduct->getChildObject()->isListingTypeFixed() || !$listingProduct->getGeneralTemplate()->getChildObject()->isVariationMode() || $listingProduct->getMagentoProduct()->isProductWithoutVariations()) {
         return array();
     }
     $tempSpecifics = array();
     if ($listingProduct->getMagentoProduct()->isConfigurableType() && $listingProduct->getDescriptionTemplate()->getChildObject()->isVariationConfigurableImages()) {
         $attributeCode = $listingProduct->getDescriptionTemplate()->getChildObject()->getVariationConfigurableImages();
         $attributeData = $listingProduct->getMagentoProduct()->getProduct()->getResource()->getAttribute($attributeCode)->getData();
         $tempProduct = $listingProduct->getMagentoProduct()->getProduct();
         $configurableAttributes = $tempProduct->getTypeInstance()->setStoreFilter($listingProduct->getListing()->getStoreId())->getConfigurableAttributesAsArray($tempProduct);
         foreach ($configurableAttributes as $configurableAttribute) {
             if ((int) $attributeData['attribute_id'] == (int) $configurableAttribute['attribute_id']) {
                 $tempSpecifics = array($configurableAttribute['label'], $configurableAttribute['frontend_label'], $configurableAttribute['store_label']);
                 break;
             }
         }
     }
     if ($listingProduct->getMagentoProduct()->isGroupedType()) {
         $tempSpecifics = array(Ess_M2ePro_Model_Magento_Product::GROUPED_PRODUCT_ATTRIBUTE_LABEL);
     }
     $requestData = array('specific' => '', 'images' => array());
     if (count($tempSpecifics) > 0) {
         $productVariations = $listingProduct->getVariations(true);
         foreach ($productVariations as $variation) {
             /** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
             if ($variation->isDelete()) {
                 continue;
             }
             $productVariationsOptions = $variation->getOptions(true);
             foreach ($productVariationsOptions as $option) {
                 /** @var $option Ess_M2ePro_Model_Listing_Product_Variation_Option */
                 $findedSpecific = false;
                 foreach ($tempSpecifics as $tempSpecific) {
                     if (strtolower($tempSpecific) == strtolower($option->getAttribute())) {
                         $findedSpecific = $option->getAttribute();
                     }
                 }
                 if ($findedSpecific === false) {
                     continue;
                 }
                 $requestData['specific'] = $findedSpecific;
                 $images = $option->getChildObject()->getImagesForEbay();
                 if (count($images) > 0) {
                     $requestData['images'][$option->getOption()] = array_slice($images, 0, 1);
                     /*!isset($requestData['images'][$option->getOption()]) &&
                        $requestData['images'][$option->getOption()] = array();
                       $requestData['images'][$option->getOption()] =
                       array_merge($requestData['images'][$option->getOption()],$images);
                       $requestData['images'][$option->getOption()] =
                       array_unique($requestData['images'][$option->getOption()]);
                       $requestData['images'][$option->getOption()] =
                       array_slice($requestData['images'][$option->getOption()],0,12);*/
                 }
             }
         }
     }
     if ($requestData['specific'] == '' || count($requestData['images']) <= 0) {
         return array();
     }
     return $requestData;
 }
Ejemplo n.º 18
0
 protected function createNewAmazonItem(Ess_M2ePro_Model_Listing_Product $listingProduct, $sku)
 {
     $dataForAdd = array('account_id' => (int) $listingProduct->getListing()->getAccountId(), 'marketplace_id' => (int) $listingProduct->getListing()->getMarketplaceId(), 'sku' => $sku, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
     if ($listingProduct->getChildObject()->isVariationMatched() && $listingProduct->getChildObject()->isVariationProduct()) {
         $variations = $listingProduct->getVariations(true);
         /* @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
         $variation = reset($variations);
         $options = $variation->getOptions();
         $dataForAdd['variation_options'] = array();
         foreach ($options as $optionData) {
             $dataForAdd['variation_options'][$optionData['attribute']] = $optionData['option'];
         }
         $dataForAdd['variation_options'] = json_encode($dataForAdd['variation_options']);
     }
     return Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save()->getId();
 }
Ejemplo n.º 19
0
 private function updateListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct, $generalId)
 {
     $tempSku = $listingProduct->getChildObject()->getAddingSku();
     $data = array('general_id' => $generalId, 'sku' => $tempSku, 'existance_check_status' => Ess_M2ePro_Model_Buy_Listing_Product::EXISTANCE_CHECK_STATUS_FOUND, 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
     $listingProduct->addData($data)->save();
     $dataForAdd = array('account_id' => $listingProduct->getListing()->getGeneralTemplate()->getAccountId(), 'marketplace_id' => $listingProduct->getListing()->getGeneralTemplate()->getMarketplaceId(), 'sku' => $tempSku, 'product_id' => $listingProduct->getProductId(), 'store_id' => $listingProduct->getListing()->getStoreId());
     Mage::getModel('M2ePro/Buy_Item')->setData($dataForAdd)->save();
     $message = Mage::helper('M2ePro')->__('The product was found in your Rakuten.com inventory and linked by Reference ID.');
     $this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
 }
Ejemplo n.º 20
0
 /**
  * @param Ess_M2ePro_Model_Listing_Product $listingProduct
  * @return bool
  * @throws Ess_M2ePro_Model_Exception
  * @throws Ess_M2ePro_Model_Exception_Logic
  */
 public function isMeetStopRequirements(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     if (!$listingProduct->isListed() || $listingProduct->isBlocked()) {
         return false;
     }
     if (!$listingProduct->isStoppable()) {
         return false;
     }
     /** @var Ess_M2ePro_Model_Amazon_Listing_Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     $variationManager = $amazonListingProduct->getVariationManager();
     if ($variationManager->isVariationProduct()) {
         if ($variationManager->isRelationParentType()) {
             return false;
         }
     }
     if ($listingProduct->isLockedObject('in_action')) {
         return false;
     }
     $amazonSynchronizationTemplate = $amazonListingProduct->getAmazonSynchronizationTemplate();
     $variationResource = Mage::getResourceModel('M2ePro/Listing_Product_Variation');
     if ($amazonSynchronizationTemplate->isStopStatusDisabled()) {
         if (!$listingProduct->getMagentoProduct()->isStatusEnabled()) {
             return true;
         } else {
             if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) {
                 $temp = $variationResource->isAllStatusesDisabled($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($amazonSynchronizationTemplate->isStopOutOfStock()) {
         if (!$listingProduct->getMagentoProduct()->isStockAvailability()) {
             return true;
         } else {
             if ($variationManager->isPhysicalUnit() && $variationManager->getTypeModel()->isVariationProductMatched()) {
                 $temp = $variationResource->isAllDoNotHaveStockAvailabilities($listingProduct->getId(), $listingProduct->getListing()->getStoreId());
                 if (!is_null($temp) && $temp) {
                     return true;
                 }
             }
         }
     }
     if ($amazonSynchronizationTemplate->isStopWhenQtyMagentoHasValue()) {
         $productQty = (int) $amazonListingProduct->getQty(true);
         $typeQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueType();
         $minQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueMin();
         $maxQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyMagentoHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     if ($amazonSynchronizationTemplate->isStopWhenQtyCalculatedHasValue()) {
         $productQty = (int) $amazonListingProduct->getQty(false);
         $typeQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueType();
         $minQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueMin();
         $maxQty = (int) $amazonSynchronizationTemplate->getStopWhenQtyCalculatedHasValueMax();
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_LESS && $productQty <= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_MORE && $productQty >= $minQty) {
             return true;
         }
         if ($typeQty == Ess_M2ePro_Model_Amazon_Template_Synchronization::STOP_QTY_BETWEEN && $productQty >= $minQty && $productQty <= $maxQty) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 21
0
 private function duplicateListingProduct(Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $duplicatedListingProduct = $listingProduct->getListing()->addProduct($listingProduct->getProductId(), false, false);
     $variationManager = $listingProduct->getChildObject()->getVariationManager();
     if (!$variationManager->isVariationProduct()) {
         return $duplicatedListingProduct;
     }
     if ($listingProduct->isComponentModeAmazon()) {
         $duplicatedListingProductManager = $duplicatedListingProduct->getChildObject()->getVariationManager();
         if ($variationManager->isIndividualType() && $duplicatedListingProductManager->modeCanBeSwitched()) {
             $duplicatedListingProductManager->switchModeToAnother();
         }
     }
     return $duplicatedListingProduct;
 }
Ejemplo n.º 22
0
 protected function createNewEbayItemsId(Ess_M2ePro_Model_Listing_Product $listingProduct, $ebayRealItemId)
 {
     $dataForAdd = array('item_id' => (double) $ebayRealItemId, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
     return Mage::getModel('M2ePro/Ebay_Item')->setData($dataForAdd)->save()->getId();
 }
Ejemplo n.º 23
0
 public function __construct(array $params = array(), Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $this->listingProduct = $listingProduct;
     parent::__construct($params, $this->listingProduct->getListing());
 }