Пример #1
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Other $listingOtherProduct
  * @param bool $checkingMode
  * @param bool $checkHasProduct
  * @return bool|\Ess\M2ePro\Model\Listing\Product
  * @throws \Ess\M2ePro\Model\Exception\Logic
  */
 public function addProductFromOther(\Ess\M2ePro\Model\Listing\Other $listingOtherProduct, $checkingMode = false, $checkHasProduct = true)
 {
     if (!$listingOtherProduct->getProductId()) {
         return false;
     }
     $productId = $listingOtherProduct->getProductId();
     $result = $this->getParentObject()->addProduct($productId, $checkingMode, true);
     if ($checkingMode) {
         return $result;
     }
     if (!$result instanceof \Ess\M2ePro\Model\Listing\Product) {
         return false;
     }
     $listingProduct = $result;
     $collection = $this->activeRecordFactory->getObject('Ebay\\Item')->getCollection()->addFieldToFilter('account_id', $listingOtherProduct->getAccount()->getId())->addFieldToFilter('item_id', $listingOtherProduct->getChildObject()->getItemId());
     $ebayItem = $collection->getLastItem();
     if (!$ebayItem->getId()) {
         $ebayItem->setData(array('account_id' => $listingOtherProduct->getAccount()->getId(), 'marketplace_id' => $listingOtherProduct->getMarketplace()->getId(), 'item_id' => $listingOtherProduct->getChildObject()->getItemId(), 'product_id' => $listingOtherProduct->getProductId()));
     }
     $ebayItem->setData('store_id', $this->getParentObject()->getStoreId())->save();
     $ebayListingProduct = $listingOtherProduct->getChildObject();
     $dataForUpdate = array('ebay_item_id' => $ebayItem->getId(), 'online_sku' => $ebayListingProduct->getSku(), 'online_title' => $ebayListingProduct->getTitle(), 'online_duration' => $ebayListingProduct->getOnlineDuration(), 'online_current_price' => $ebayListingProduct->getOnlinePrice(), 'online_qty' => $ebayListingProduct->getOnlineQty(), 'online_qty_sold' => $ebayListingProduct->getOnlineQtySold(), 'online_bids' => $ebayListingProduct->getOnlineBids(), 'start_date' => $ebayListingProduct->getStartDate(), 'end_date' => $ebayListingProduct->getEndDate(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger());
     $listingOtherAdditionalData = $listingOtherProduct->getAdditionalData();
     if (!empty($listingOtherAdditionalData['out_of_stock_control'])) {
         $listingProductAdditionalData = $listingProduct->getAdditionalData();
         $additionalDataForUpdate = array_merge($listingProductAdditionalData, array('out_of_stock_control' => true));
         $dataForUpdate['additional_data'] = json_encode($additionalDataForUpdate);
     }
     $listingProduct->addData($dataForUpdate)->getChildObject()->addData($dataForUpdate);
     $listingProduct->save();
     return $listingProduct;
 }
Пример #2
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Other $otherListing
  */
 protected function setAccountByOtherListingProduct(\Ess\M2ePro\Model\Listing\Other $otherListing)
 {
     if (!is_null($this->account) && $this->account->getId() == $otherListing->getAccountId()) {
         return;
     }
     $this->account = $this->amazonFactory->getCachedObjectLoaded('Account', $otherListing->getAccountId());
 }
Пример #3
0
 /**
  * @param \Ess\M2ePro\Model\Listing\Other $listingOtherProduct
  * @param bool $checkingMode
  * @param bool $checkHasProduct
  * @return bool|\Ess\M2ePro\Model\Listing\Product
  * @throws \Ess\M2ePro\Model\Exception\Logic
  */
 public function addProductFromOther(\Ess\M2ePro\Model\Listing\Other $listingOtherProduct, $checkingMode = false, $checkHasProduct = true)
 {
     if (!$listingOtherProduct->getProductId()) {
         return false;
     }
     $productId = $listingOtherProduct->getProductId();
     $result = $this->getParentObject()->addProduct($productId, $checkingMode, $checkHasProduct);
     if ($checkingMode) {
         return $result;
     }
     if (!$result instanceof \Ess\M2ePro\Model\Listing\Product) {
         return false;
     }
     $listingProduct = $result;
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Product $amazonListingProduct */
     $amazonListingProduct = $listingProduct->getChildObject();
     $variationManager = $amazonListingProduct->getVariationManager();
     if ($variationManager->isRelationParentType()) {
         $variationManager->switchModeToAnother();
     }
     $amazonListingProduct->getAmazonItem()->setData('store_id', $this->getParentObject()->getStoreId())->save();
     /** @var \Ess\M2ePro\Model\Amazon\Listing\Other $amazonListingOther */
     $amazonListingOther = $listingOtherProduct->getChildObject();
     $dataForUpdate = array('general_id' => $amazonListingOther->getGeneralId(), 'sku' => $amazonListingOther->getSku(), 'online_price' => $amazonListingOther->getOnlinePrice(), 'online_qty' => $amazonListingOther->getOnlineQty(), 'is_afn_channel' => (int) $amazonListingOther->isAfnChannel(), 'is_isbn_general_id' => (int) $amazonListingOther->isIsbnGeneralId(), 'status' => $listingOtherProduct->getStatus(), 'status_changer' => $listingOtherProduct->getStatusChanger());
     $listingProduct->addData($dataForUpdate);
     $amazonListingProduct->addData($dataForUpdate);
     $listingProduct->save();
     if ($amazonListingOther->isRepricing()) {
         $listingProductRepricing = $this->activeRecordFactory->getObject('Amazon\\Listing\\Product\\Repricing');
         $listingProductRepricing->setData(array('listing_product_id' => $listingProduct->getId(), 'is_online_disabled' => $amazonListingOther->isRepricingDisabled()));
         $listingProductRepricing->save();
     }
     return $listingProduct;
 }