/**
  * Exports images, variants, properties item data and items base to make sure, that the corresponding items data exist.
  */
 protected function export()
 {
     // Repository
     $Repository = Shopware()->Models()->getRepository('Shopware\\Models\\Customer\\Customer');
     // Chunk configuration
     $chunk = 0;
     do {
         PlentymarketsLogger::getInstance()->message('Export:Initial:Customer', 'Chunk: ' . ($chunk + 1));
         $Customers = $Repository->findBy(array(), null, $this->sizeOfChunk, $chunk * $this->sizeOfChunk);
         /** @var Shopware\Models\Customer\Customer $Customer */
         foreach ($Customers as $Customer) {
             try {
                 $PlentymarketsExportEntityItem = new PlentymarketsExportEntityCustomer($Customer);
                 $PlentymarketsExportEntityItem->export();
             } catch (PlentymarketsExportEntityException $E) {
                 PlentymarketsLogger::getInstance()->error('Export:Initial:Customer', $E->getMessage(), $E->getCode());
             }
         }
         ++$chunk;
     } while (!empty($Customers) && count($Customers) == $this->sizeOfChunk);
 }
 /**
  * Returns the plentymarkets customer id
  *
  * @throws PlentymarketsExportEntityException
  * @return integer
  */
 protected function getCustomerId()
 {
     try {
         return PlentymarketsMappingController::getCustomerByShopwareID($this->order['billing']['id']);
     } catch (PlentymarketsMappingExceptionNotExistant $E) {
         // Customer needs to be re-exported
         PlentymarketsLogger::getInstance()->message('Sync:Order:IncomingPayment', 'Re-exporting customer');
     }
     // Get the data
     $Customer = Shopware()->Models()->find('Shopware\\Models\\Customer\\Customer', $this->order['customerId']);
     $BillingAddress = Shopware()->Models()->find('Shopware\\Models\\Order\\Billing', $this->order['billing']['id']);
     try {
         $PlentymarketsExportEntityCustomer = new PlentymarketsExportEntityCustomer($Customer, $BillingAddress);
         $PlentymarketsExportEntityCustomer->export();
     } catch (PlentymarketsExportEntityException $E) {
         throw new PlentymarketsExportEntityException('The incoming payment of the order with the number »' . $this->order['number'] . '« could not be booked (' . $E->getMessage() . ')', 4150);
     }
     return PlentymarketsMappingController::getCustomerByShopwareID($this->order['billing']['id']);
 }
 /**
  * Export the customer
  */
 protected function exportCustomer()
 {
     $Customer = $this->Order->getCustomer();
     $Billing = $this->Order->getBilling();
     $Shipping = $this->Order->getShipping();
     //
     try {
         $PlentymarketsExportEntityOrderCustomer = new PlentymarketsExportEntityCustomer($Customer, $Billing, $Shipping);
         $PlentymarketsExportEntityOrderCustomer->export();
     } catch (PlentymarketsExportEntityException $E) {
         // Save the error
         $this->setError(self::CODE_ERROR_CUSTOMER);
         // Throw another exception
         throw new PlentymarketsExportEntityException('The order with the number »' . $this->Order->getNumber() . '« could not be exported (' . $E->getMessage() . ')', 4100);
     }
     //
     $this->PLENTY_customerID = $PlentymarketsExportEntityOrderCustomer->getPlentyCustomerID();
     $this->PLENTY_addressDispatchID = $PlentymarketsExportEntityOrderCustomer->getPlentyAddressDispatchID();
 }