/** * @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 } } }
/** * @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 } } }
/** * 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 } } }