/**
  * Exports the images of the item
  */
 protected function exportImages()
 {
     /**
      * @var Shopware\Models\Article\Image $Image
      * @var Shopware\Models\Media\Media $ImageMedia
      */
     foreach ($this->SHOPWARE_Article->getImages() as $Image) {
         $ImageMedia = $Image->getMedia();
         if (is_null($ImageMedia)) {
             PlentymarketsLogger::getInstance()->error('Export:Initial:Item:Image', 'The image with the id »' . $Image->getId() . '« could not be added to the item with the number »' . $this->SHOPWARE_Article->getMainDetail()->getNumber() . '« (no media associated)', 2850);
             continue;
         }
         try {
             if ('___VERSION___' !== Shopware::VERSION && version_compare(Shopware::VERSION, '5.1.0', '<')) {
                 $fullpath = Shopware()->DocPath() . $ImageMedia->getPath();
             } else {
                 /**
                  * @var \Shopware\Bundle\MediaBundle\MediaService $mediaService
                  */
                 $mediaService = Shopware()->Container()->get('shopware_media.media_service');
                 $fullpath = $mediaService->getUrl($ImageMedia->getPath());
             }
         } catch (Exception $E) {
             PlentymarketsLogger::getInstance()->error('Export:Initial:Item:Image', 'The image with the id »' . $Image->getId() . '« could not be added to the item with the number »' . $this->SHOPWARE_Article->getMainDetail()->getNumber() . '« (' . $E->getMessage() . ')', 2860);
             continue;
         }
         $Request_SetItemImages = new PlentySoapRequest_SetItemImages();
         $Request_SetItemImages->Images = array();
         $RequestObject_SetItemImagesImage = new PlentySoapRequestObject_SetItemImagesImage();
         $RequestObject_SetItemImagesImage->ImageFileName = $Image->getPath();
         $RequestObject_SetItemImagesImage->ImageFileData = base64_encode(file_get_contents($fullpath));
         $RequestObject_SetItemImagesImage->ImageFileEnding = $Image->getExtension();
         $RequestObject_SetItemImagesImage->ImageID = null;
         // int
         $RequestObject_SetItemImagesImage->ImageURL = null;
         // string
         $RequestObject_SetItemImagesImage->Position = $Image->getPosition();
         $mappings = $Image->getMappings();
         if (count($mappings)) {
             /** @var Shopware\Models\Article\Image\Mapping $mapping */
             $mapping = $mappings->first();
             $rules = $mapping->getRules();
             if (count($rules)) {
                 /** @var Shopware\Models\Article\Image\Rule $rule */
                 $rule = $rules->first();
                 $option = $rule->getOption();
                 $group = $option->getGroup();
                 //	$Request_SetItemImages->ItemAttributeID = PlentymarketsMappingController::getAttributeGroupByShopwareID($group->getId());
                 $RequestObject_SetItemImagesImage->AttributeValueId = PlentymarketsMappingController::getAttributeOptionByShopwareID($option->getId());
             }
         }
         $RequestObject_SetItemImagesImage->Names = array();
         $RequestObject_SetItemImagesImageName = new PlentySoapRequestObject_SetItemImagesImageName();
         if (!is_null(PlentymarketsConfig::getInstance()->getItemImageAltAttributeID()) && PlentymarketsConfig::getInstance()->getItemImageAltAttributeID() > 0 && PlentymarketsConfig::getInstance()->getItemImageAltAttributeID() <= 3) {
             // get the attribute number for alternative text from connector's settings
             $plenty_attributeID = PlentymarketsConfig::getInstance()->getItemImageAltAttributeID();
             //check if the attribute value is set for the image
             if (method_exists($Image->getAttribute(), 'getAttribute' . $plenty_attributeID)) {
                 // set the value of the attribute as alternative text for the  image
                 $RequestObject_SetItemImagesImageName->AlternativeText = $Image->getAttribute()->{getAttribute . $plenty_attributeID}();
                 // string
             }
         }
         $RequestObject_SetItemImagesImageName->DeleteName = false;
         // boolean
         $RequestObject_SetItemImagesImageName->Lang = 'de';
         // string
         $RequestObject_SetItemImagesImageName->Name = $Image->getDescription();
         // string
         $RequestObject_SetItemImagesImage->Names[] = $RequestObject_SetItemImagesImageName;
         // export the image title translations
         $image_NameTranslations = $this->getImageTitleTranslations($Image->getId());
         foreach ($image_NameTranslations as $lang => $titleTranslation) {
             $RequestObject_SetItemImagesImageName = new PlentySoapRequestObject_SetItemImagesImageName();
             $RequestObject_SetItemImagesImageName->DeleteName = false;
             // boolean
             $RequestObject_SetItemImagesImageName->Lang = $lang;
             // string
             $RequestObject_SetItemImagesImageName->Name = $titleTranslation;
             // string
             $RequestObject_SetItemImagesImage->Names[] = $RequestObject_SetItemImagesImageName;
         }
         // set the plenty store ids for references
         $RequestObject_SetItemImagesImage->References = array();
         $plentyStoreIds = array();
         /** @var Shopware\Models\Category\Category $Category */
         foreach ($this->SHOPWARE_Article->getCategories() as $Category) {
             // Get the store for this category
             $rootId = PlentymarketsUtils::getRootIdByCategory($Category);
             $shops = PlentymarketsUtils::getShopIdByCategoryRootId($rootId);
             foreach ($shops as $shopId) {
                 try {
                     $plentyStoreId = PlentymarketsMappingController::getShopByShopwareID($shopId);
                     if (!in_array($plentyStoreId, $plentyStoreIds)) {
                         $plentyStoreIds[] = $plentyStoreId;
                     }
                 } catch (PlentymarketsMappingExceptionNotExistant $E) {
                     continue;
                 }
             }
         }
         foreach ($plentyStoreIds as $storeId) {
             $RequestObject_SetItemImagesImageReference = new PlentySoapRequestObject_SetItemImagesImageReference();
             $RequestObject_SetItemImagesImageReference->DeleteReference = false;
             // boolean
             //$Enumeration_SetItemImagesImageReferenceType = new PlentySoapEnumeration_SetItemImagesImageReferenceType();
             $RequestObject_SetItemImagesImageReference->ReferenceType = 'Mandant';
             $RequestObject_SetItemImagesImageReference->ReferenceValue = $storeId;
             // int
             $RequestObject_SetItemImagesImage->References[] = $RequestObject_SetItemImagesImageReference;
         }
         $Request_SetItemImages->Images[] = $RequestObject_SetItemImagesImage;
         $Request_SetItemImages->ItemID = $this->PLENTY_itemID;
         // Do the request
         PlentymarketsSoapClient::getInstance()->SetItemImages($Request_SetItemImages);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getCategories()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCategories', array());
     return parent::getCategories();
 }