/**
  * @param array $params
  * @param Ess_M2ePro_Model_Listing_Product[] $listingsProducts
  * @throws Exception
  */
 public function __construct(array $params = array(), array $listingsProducts)
 {
     if (empty($listingsProducts)) {
         throw new Exception('Multiple Item Connector has received empty array');
     }
     /** @var Ess_M2ePro_Model_Account $account */
     $account = reset($listingsProducts)->getAccount();
     /** @var Ess_M2ePro_Model_Marketplace $marketplace */
     $marketplace = reset($listingsProducts)->getMarketplace();
     $listingProductIds = array();
     foreach ($listingsProducts as $listingProduct) {
         if (!$listingProduct instanceof Ess_M2ePro_Model_Listing_Product) {
             throw new Exception('Multiple Item Connector has received invalid Product data type');
         }
         if ($account->getId() != $listingProduct->getListing()->getAccountId()) {
             throw new Exception('Multiple Item Connector has received Products from different Accounts');
         }
         if ($marketplace->getId() != $listingProduct->getListing()->getMarketplaceId()) {
             throw new Exception('Multiple Item Connector has received Products from different Marketplaces');
         }
         $listingProductIds[] = $listingProduct->getId();
     }
     /** @var Ess_M2ePro_Model_Mysql4_Listing_Product_Collection $listingProductCollection */
     $listingProductCollection = Mage::helper('M2ePro/Component_Ebay')->getCollection('Listing_Product');
     $listingProductCollection->addFieldToFilter('id', array('in' => array_unique($listingProductIds)));
     $actualListingsProducts = $listingProductCollection->getItems();
     if (empty($actualListingsProducts)) {
         throw new Exception('All products were removed before connector processing');
     }
     $this->listingsProducts = $actualListingsProducts;
     parent::__construct($params, $marketplace, $account);
 }
 public function __construct(array $params = array(), Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     if (!is_null($listingProduct->getActionConfigurator())) {
         $actionConfigurator = $listingProduct->getActionConfigurator();
     } else {
         $actionConfigurator = Mage::getModel('M2ePro/Ebay_Listing_Product_Action_Configurator');
     }
     $this->listingProduct = $listingProduct->loadInstance($listingProduct->getId());
     $this->listingProduct->setActionConfigurator($actionConfigurator);
     parent::__construct($params, $this->listingProduct->getMarketplace(), $this->listingProduct->getAccount());
 }
예제 #3
0
 public function __construct(array $params = array(), array $listingsProducts)
 {
     if (count($listingsProducts) == 0) {
         throw new Exception('Multiple Item Connector has received empty array');
     }
     foreach ($listingsProducts as $listingProduct) {
         if (!$listingProduct instanceof Ess_M2ePro_Model_Listing_Product) {
             throw new Exception('Multiple Item Connector has received invalid product data type');
         }
     }
     $tempListing = $listingsProducts[0]->getListing();
     foreach ($listingsProducts as $listingProduct) {
         if ($tempListing->getId() != $listingProduct->getListing()->getId()) {
             throw new Exception('Multiple Item Connector has received products from different listings');
         }
     }
     $this->listingsProducts = $listingsProducts;
     parent::__construct($params, $tempListing);
 }
예제 #4
0
 public function __construct(array $params = array(), Ess_M2ePro_Model_Listing_Product $listingProduct)
 {
     $this->listingProduct = $listingProduct;
     parent::__construct($params, $this->listingProduct->getMarketplace(), $this->listingProduct->getAccount());
 }