/**
  * Run import of property groups and property translations
  * @param int $lastUpdateTimestamp
  */
 private function runImportTranslations($lastUpdateTimestamp)
 {
     $mainShops = PlentymarketsUtils::getShopwareMainShops();
     /** @var $mainShop Shopware\Models\Shop\Shop */
     foreach ($mainShops as $mainShop) {
         // get all active languages of the main shop
         $activeLanguages = PlentymarketsTranslation::getShopActiveLanguages($mainShop->getId());
         foreach ($activeLanguages as $key => $language) {
             // import tanslation for property group
             $Request_GetPropertyGroups = new PlentySoapRequest_GetPropertyGroups();
             $Request_GetPropertyGroups->Lang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']);
             $Request_GetPropertyGroups->LastUpdateFrom = $lastUpdateTimestamp;
             $Request_GetPropertyGroups->Page = 0;
             do {
                 /** @var PlentySoapResponse_GetPropertyGroups $Response_GetPropertyGroups */
                 $Response_GetPropertyGroups = PlentymarketsSoapClient::getInstance()->GetPropertyGroups($Request_GetPropertyGroups);
                 foreach ($Response_GetPropertyGroups->PropertyGroups->item as $group) {
                     $PlentymarketsImportEntityItemPropertyGroup = new PlentymarketsImportEntityItemPropertyGroup($group);
                     // set the property group translations from plenty for the language shops
                     if (!is_null($language['mainShopId'])) {
                         $languageShopID = PlentymarketsTranslation::getLanguageShopID($key, $language['mainShopId']);
                         $PlentymarketsImportEntityItemPropertyGroup->importPropertyGroupTranslation($languageShopID);
                     } else {
                         $PlentymarketsImportEntityItemPropertyGroup->importPropertyGroupTranslation($mainShop->getId());
                     }
                 }
             } while (++$Request_GetPropertyGroups->Page < $Response_GetPropertyGroups->Pages);
             // import translation for properties
             $Request_GetProperties = new PlentySoapRequest_GetProperties();
             $Request_GetProperties->Lang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']);
             $Request_GetProperties->LastUpdateFrom = $lastUpdateTimestamp;
             $Request_GetProperties->Page = 0;
             do {
                 /** @var PlentySoapResponse_GetProperties $Response_GetProperties */
                 $Response_GetProperties = PlentymarketsSoapClient::getInstance()->GetProperties($Request_GetProperties);
                 foreach ($Response_GetProperties->Properties->item as $Option) {
                     $PlentymarketsImportEntityItemPropertyOption = new PlentymarketsImportEntityItemPropertyOption($Option);
                     // set the property translations from plenty for the language shops
                     if (!is_null($language['mainShopId'])) {
                         $languageShopID = PlentymarketsTranslation::getLanguageShopID($key, $language['mainShopId']);
                         $PlentymarketsImportEntityItemPropertyOption->importPropertyTranslation($languageShopID);
                     } else {
                         // set the property translation for the main shop
                         $PlentymarketsImportEntityItemPropertyOption->importPropertyTranslation($mainShop->getId());
                     }
                 }
             } while (++$Request_GetProperties->Page < $Response_GetProperties->Pages);
         }
     }
 }
 /**
  * Performs the actual import
  *
  * @param integer $lastUpdateTimestamp
  */
 public function run($lastUpdateTimestamp)
 {
     $Request_GetItemAttributes = new PlentySoapRequest_GetItemAttributes();
     $Request_GetItemAttributes->GetValues = true;
     $Request_GetItemAttributes->LastUpdateFrom = $lastUpdateTimestamp;
     /** @var PlentySoapResponse_GetItemAttributes $Response_GetItemAttributes */
     $Response_GetItemAttributes = PlentymarketsSoapClient::getInstance()->GetItemAttributes($Request_GetItemAttributes);
     if (!$Response_GetItemAttributes->Success) {
         return;
     }
     foreach ($Response_GetItemAttributes->Attributes->item as $Attribute) {
         $PlentymarketsImportEntityItemAttribute = new PlentymarketsImportEntityItemAttribute($Attribute);
         $PlentymarketsImportEntityItemAttribute->import();
     }
     // run import of attributes and attributes value translations
     $mainShops = PlentymarketsUtils::getShopwareMainShops();
     /** @var $mainShop Shopware\Models\Shop\Shop */
     foreach ($mainShops as $mainShop) {
         // get all active languages of the main shop
         $activeLanguages = PlentymarketsTranslation::getShopActiveLanguages($mainShop->getId());
         foreach ($activeLanguages as $key => $language) {
             $Request_GetItemAttributes = new PlentySoapRequest_GetItemAttributes();
             $Request_GetItemAttributes->GetValues = true;
             $Request_GetItemAttributes->LastUpdateFrom = $lastUpdateTimestamp;
             $Request_GetItemAttributes->Lang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']);
             /** @var PlentySoapResponse_GetItemAttributes $Response_GetItemAttributes */
             $Response_GetItemAttributes = PlentymarketsSoapClient::getInstance()->GetItemAttributes($Request_GetItemAttributes);
             if ($Response_GetItemAttributes->Success) {
                 foreach ($Response_GetItemAttributes->Attributes->item as $Attribute) {
                     $PlentymarketsImportEntityItemAttribute = new PlentymarketsImportEntityItemAttribute($Attribute);
                     // set the atrribute translations from plenty for the language shops
                     if (!is_null($language['mainShopId'])) {
                         $languageShopID = PlentymarketsTranslation::getLanguageShopID($key, $language['mainShopId']);
                         $PlentymarketsImportEntityItemAttribute->importTranslation($languageShopID);
                     } else {
                         // import translations for the main shop languages
                         $PlentymarketsImportEntityItemAttribute->importTranslation($mainShop->getId());
                     }
                 }
             }
         }
     }
 }
 /**
  * @param int $shopware_propertyID
  * @param int $plenty_propertyID
  */
 protected function exportPropertyGroupTranslations($shopware_propertyID, $plenty_propertyID)
 {
     $Request_SetPropertyGroups = new PlentySoapRequest_SetPropertyGroups();
     $Request_SetPropertyGroups->PropertyGroups = array();
     $mainShops = PlentymarketsUtils::getShopwareMainShops();
     /** @var $mainShop Shopware\Models\Shop\Shop */
     foreach ($mainShops as $mainShop) {
         // get all active languages of the main shop
         $activeLanguages = PlentymarketsTranslation::getShopActiveLanguages($mainShop->getId());
         foreach ($activeLanguages as $key => $language) {
             // export the property group translations of the language shops and main shops
             // try to get translation
             $propertyGroupTranslation = PlentymarketsTranslation::getShopwareTranslation($mainShop->getId(), 'propertygroup', $shopware_propertyID, $key);
             // if the translation was found, do export
             if (!is_null($propertyGroupTranslation) && isset($propertyGroupTranslation['groupName'])) {
                 $Object_SetPropertyGroup = new PlentySoapObject_SetPropertyGroup();
                 $Object_SetPropertyGroup->PropertyGroupID = $plenty_propertyID;
                 $Object_SetPropertyGroup->Lang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']);
                 $Object_SetPropertyGroup->FrontendName = $propertyGroupTranslation['groupName'];
                 $Request_SetPropertyGroups->PropertyGroups[] = $Object_SetPropertyGroup;
             }
         }
     }
     if (!empty($Request_SetPropertyGroups->PropertyGroups)) {
         $Response = PlentymarketsSoapClient::getInstance()->SetPropertyGroups($Request_SetPropertyGroups);
         if (!$Response->Success) {
             // throw exception
         }
     }
 }
 /**
  * @description Export the translation of the attributes and attributes values that are set for the language shops in shopware
  * @param int $shopwareAttributeID
  * @param int $plentyAttributeID
  */
 private function exportAttributeTranslations($shopwareAttributeID, $plentyAttributeID)
 {
     $Request_SetItemAttributes = new PlentySoapRequest_SetItemAttributes();
     $mainShops = PlentymarketsUtils::getShopwareMainShops();
     /** @var $mainShop Shopware\Models\Shop\Shop */
     foreach ($mainShops as $mainShop) {
         $Request_SetItemAttributes = new PlentySoapRequest_SetItemAttributes();
         // get all active languages of the main shop
         $activeLanguages = PlentymarketsTranslation::getShopActiveLanguages($mainShop->getId());
         foreach ($activeLanguages as $key => $language) {
             // export the atrribute translations of the language shops and main shops
             // try to get translation
             $attrTranslation = PlentymarketsTranslation::getShopwareTranslation($mainShop->getId(), 'configuratorgroup', $shopwareAttributeID, $key);
             // if the translation was found, do export
             if (!is_null($attrTranslation) && isset($attrTranslation['name'])) {
                 $Object_SetItemAttribute = new PlentySoapObject_SetItemAttribute();
                 $Object_SetItemAttribute->Id = $plentyAttributeID;
                 $Object_SetItemAttribute->FrontendLang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']);
                 $Object_SetItemAttribute->FrontendName = $attrTranslation['name'];
                 $Request_SetItemAttributes->Attributes[] = $Object_SetItemAttribute;
             }
         }
     }
     if (!empty($Request_SetItemAttributes->Attributes)) {
         $Response = PlentymarketsSoapClient::getInstance()->SetItemAttributes($Request_SetItemAttributes);
         if (!$Response->Success) {
             // throw exception
         }
     }
 }
 /**
  * Export the property value translations of the main shops and language shops
  * @param int $shopware_propertyID
  * @param int $plenty_propertyID
  */
 protected function exportPropertyValueTranslations($shopware_propertyID, $plenty_propertyID)
 {
     $Request_SetPropertiesToItem = new PlentySoapRequest_SetPropertiesToItem();
     $Request_SetPropertiesToItem->PropertyToItemList = array();
     $mainShops = PlentymarketsUtils::getShopwareMainShops();
     /** @var $mainShop Shopware\Models\Shop\Shop */
     foreach ($mainShops as $mainShop) {
         // get all active languages of the main shop
         $activeLanguages = PlentymarketsTranslation::getShopActiveLanguages($mainShop->getId());
         foreach ($activeLanguages as $key => $language) {
             // export the property value translations of the language shops and main shops
             // try to get the property value translation
             $propertyValueTranslation = PlentymarketsTranslation::getShopwareTranslation($mainShop->getId(), 'propertyvalue', $shopware_propertyID, $key);
             // if the translation was found, do export
             if (!is_null($propertyValueTranslation) && isset($propertyValueTranslation['optionValue'])) {
                 $Object_SetPropertyToItem = new PlentySoapObject_SetPropertyToItem();
                 $Object_SetPropertyToItem->ItemId = $this->PLENTY_itemID;
                 // int
                 $Object_SetPropertyToItem->PropertyId = $plenty_propertyID;
                 $Object_SetPropertyToItem->Lang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']);
                 $Object_SetPropertyToItem->PropertyItemValue = $propertyValueTranslation['optionValue'];
                 $Request_SetPropertiesToItem->PropertyToItemList[] = $Object_SetPropertyToItem;
             }
         }
     }
     if (!empty($Request_SetPropertiesToItem->PropertyToItemList)) {
         $Response_SetPropertiesToItem = PlentymarketsSoapClient::getInstance()->SetPropertiesToItem($Request_SetPropertiesToItem);
         if (!$Response_SetPropertiesToItem) {
             // throw exception
         }
     }
 }