/** * imports the item for the given shop * * @param integer $itemId * @param integer $storeId * @throws PlentymarketsImportException */ public function importItem($itemId, $storeId) { // Check whether the item has already been imported $full = !isset($this->itemIdsDone[$itemId]); // Build the request $Request_GetItemsBase = new PlentySoapRequest_GetItemsBase(); $Request_GetItemsBase->GetAttributeValueSets = $full; $Request_GetItemsBase->GetCategories = true; $Request_GetItemsBase->GetCategoryNames = true; $Request_GetItemsBase->GetItemAttributeMarkup = $full; $Request_GetItemsBase->GetItemOthers = $full; //$Request_GetItemsBase->GetItemProperties = $full; $Request_GetItemsBase->GetItemProperties = true; $Request_GetItemsBase->GetItemSuppliers = false; $Request_GetItemsBase->GetItemURL = 0; $Request_GetItemsBase->GetLongDescription = $full; $Request_GetItemsBase->GetMetaDescription = false; $Request_GetItemsBase->GetShortDescription = $full; $Request_GetItemsBase->GetTechnicalData = false; $Request_GetItemsBase->StoreID = $storeId; $Request_GetItemsBase->ItemID = $itemId; // get the main language of the shop //$mainLang = array_values(PlentymarketsTranslation::getInstance()->getShopMainLanguage(PlentymarketsMappingController::getShopByPlentyID($storeId))); // set the main language of the shop in soap request //$Request_GetItemsBase->Lang = PlentymarketsTranslation::getInstance()->getPlentyLocaleFormat($mainLang[0]['locale']); $Request_GetItemsBase->Lang = 'de'; // Do the request $Response_GetItemsBase = PlentymarketsSoapClient::getInstance()->GetItemsBase($Request_GetItemsBase); // On error if ($Response_GetItemsBase->Success == false) { // Re-add the item to the stack and quit PlentymarketsImportStackItem::getInstance()->addItem($itemId, $storeId); return; } // Item not found if (!isset($Response_GetItemsBase->ItemsBase->item[0])) { return; } // $ItemBase = $Response_GetItemsBase->ItemsBase->item[0]; // Skip bundles if ($ItemBase->BundleType == 'bundle' && PlentymarketsConfig::getInstance()->getItemBundleHeadActionID(IMPORT_ITEM_BUNDLE_HEAD_NO) == IMPORT_ITEM_BUNDLE_HEAD_NO) { PlentymarketsLogger::getInstance()->message('Sync:Item', 'The item »' . $ItemBase->Texts->Name . '« will be skipped (bundle)'); return; } // get the item texts in all active languages $itemTexts = array(); $shopId = PlentymarketsMappingController::getShopByPlentyID($storeId); //if this is a main shop , get the item texts translation for its main language and its shop languages if (PlentymarketsTranslation::isMainShop($shopId)) { // get all active languages of the shop (from shopware) $activeLanguages = PlentymarketsTranslation::getShopActiveLanguages($shopId); foreach ($activeLanguages as $localeId => $language) { $Request_GetItemsTexts = new PlentySoapRequest_GetItemsTexts(); $Request_GetItemsTexts->ItemsList = array(); $Object_RequestItems = new PlentySoapObject_RequestItems(); $Object_RequestItems->ExternalItemNumer = null; // string $Object_RequestItems->ItemId = $itemId; // string $Object_RequestItems->ItemNumber = null; // string $Object_RequestItems->Lang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']); // string $Request_GetItemsTexts->ItemsList[] = $Object_RequestItems; $Response_GetItemsTexts = PlentymarketsSoapClient::getInstance()->GetItemsTexts($Request_GetItemsTexts); if (isset($Response_GetItemsTexts->ItemTexts->item[0])) { $itemText = array(); // save the language infos for the item texts $itemText['locale'] = $language['locale']; // if mainShopId == null, then it is the main shop and no language shop // each language shop has a mainShopId if (!is_null($language['mainShopId'])) { $itemText['languageShopId'] = PlentymarketsTranslation::getLanguageShopID($localeId, $language['mainShopId']); } elseif (PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']) != 'de') { // set the language for the main shop if the main language is not German $itemText['languageShopId'] = $shopId; } $itemText['texts'] = $Response_GetItemsTexts->ItemTexts->item[0]; $itemTexts[] = $itemText; } } } try { $shopId = PlentymarketsMappingController::getShopByPlentyID($storeId); $Shop = Shopware()->Models()->find('Shopware\\Models\\Shop\\Shop', $shopId); $Importuer = new PlentymarketsImportEntityItem($ItemBase, $Shop); // The item has already been updated if (!$full) { // so we just need to do the categories $Importuer->importCategories(); //if this is a main shop , import the translation for its main language and its shop languages if (PlentymarketsTranslation::isMainShop($shopId)) { if (!empty($itemTexts)) { // Do the import for item texts translation $Importuer->saveItemTextsTranslation($itemTexts); } // Do the import for the property value translations $Importuer->importItemPropertyValueTranslations(); } } else { // Do a full import $Importuer->import(); //if this is a main shop , import the translation for its main language and its shop languages if (PlentymarketsTranslation::isMainShop($shopId)) { if (!empty($itemTexts)) { // Do the import for item texts translation $Importuer->saveItemTextsTranslation($itemTexts); } // Do the import for the property value translations $Importuer->importItemPropertyValueTranslations(); } // Add it to the link controller PlentymarketsImportControllerItemLinked::getInstance()->addItem($ItemBase->ItemID); // Mark this item as done $this->itemIdsDone[$ItemBase->ItemID] = true; } // Log the usage data PyLog()->usage(); } catch (Shopware\Components\Api\Exception\ValidationException $E) { PlentymarketsLogger::getInstance()->error('Sync:Item:Validation', 'The item »' . $ItemBase->Texts->Name . '« with the id »' . $ItemBase->ItemID . '« could not be imported', 3010); foreach ($E->getViolations() as $ConstraintViolation) { PlentymarketsLogger::getInstance()->error('Sync:Item:Validation', $ConstraintViolation->getMessage()); PlentymarketsLogger::getInstance()->error('Sync:Item:Validation', $ConstraintViolation->getPropertyPath() . ': ' . $ConstraintViolation->getInvalidValue()); } } catch (Shopware\Components\Api\Exception\OrmException $E) { PlentymarketsLogger::getInstance()->error('Sync:Item:Orm', 'The item »' . $ItemBase->Texts->Name . '« with the id »' . $ItemBase->ItemID . '« could not be imported (' . $E->getMessage() . ')', 3020); PlentymarketsLogger::getInstance()->error('Sync:Item:Orm', $E->getTraceAsString(), 1000); throw new PlentymarketsImportException('The item import will be stopped (internal database error)', 3021); } catch (PlentymarketsImportItemNumberException $E) { PlentymarketsLogger::getInstance()->error('Sync:Item:Number', $E->getMessage(), $E->getCode()); } catch (PlentymarketsImportItemException $E) { PlentymarketsLogger::getInstance()->error('Sync:Item:Number', $E->getMessage(), $E->getCode()); } catch (Exception $E) { PlentymarketsLogger::getInstance()->error('Sync:Item', 'The item »' . $ItemBase->Texts->Name . '« with the id »' . $ItemBase->ItemID . '« could not be imported', 3000); PlentymarketsLogger::getInstance()->error('Sync:Item', $E->getTraceAsString(), 1000); PlentymarketsLogger::getInstance()->error('Sync:Item', get_class($E)); PlentymarketsLogger::getInstance()->error('Sync:Item', $E->getMessage()); } }
/** * Retrieves the images from plentymarkets and adds them to the item. * * @return number */ public function image() { $plentyId2ShopwareId = array(); $shopwareId2PlentyPosition = array(); $Request_GetItemsImages = new PlentySoapRequest_GetItemsImages(); $Request_GetItemsImages->Page = 0; $Request_GetItemsImages->SKU = $this->PLENTY_itemId; // Cleanup $this->purge(); /** * @var Media $mediaResource */ $mediaResource = \Shopware\Components\Api\Manager::getResource('Media'); do { /** * @var PlentySoapResponse_GetItemsImages $Response_GetItemsImages */ $Response_GetItemsImages = PlentymarketsSoapClient::getInstance()->GetItemsImages($Request_GetItemsImages); if ($Response_GetItemsImages->Success == false) { PlentymarketsLogger::getInstance()->error('Sync:Item:Image', 'The images for the plentymarkets item id »' . $this->PLENTY_itemId . '« could not be retrieved', 3200); continue; } /** * @var $Image PlentySoapResponse_ObjectItemImage */ foreach ($Response_GetItemsImages->ItemsImages->item as $Image) { $shopwareStoreIds = array(); /** * @var $reference PlentySoapResponse_ObjectGetItemImageReference */ foreach ($Image->References->item as $reference) { if ($reference->ReferenceType == 'Mandant') { try { if (PlentymarketsMappingController::getShopByPlentyID($reference->ReferenceValue) > 0) { $shopwareStoreId = PlentymarketsMappingController::getShopByPlentyID($reference->ReferenceValue); } } catch (PlentymarketsMappingExceptionNotExistant $E) { continue; } if (isset($shopwareStoreId)) { $shopwareStoreIds[] = $shopwareStoreId; } } } // Skip the image if it should not be shown if (empty($shopwareStoreIds)) { continue; } else { try { $media = $this->updateMedia($Image, $mediaResource); } catch (PlentymarketsMappingExceptionNotExistant $e) { $media = $this->createMedia($Image, $mediaResource); } catch (NotFoundException $e) { $media = $this->createMedia($Image, $mediaResource); } catch (Exception $e) { PlentymarketsLogger::getInstance()->error('Sync:Item:Image', $e->getMessage(), 3200); continue; } $image = new Image(); $image->setMain(2); $image->setMedia($media); $image->setPath($media->getName()); $image->setExtension($media->getExtension()); // get the main language of the shop //$mainLangData = array_values(PlentymarketsTranslation::getInstance()->getShopMainLanguage($shopwareStoreId)); //$mainLang = PlentymarketsTranslation::getInstance()->getPlentyLocaleFormat($mainLangData[0]['locale']); foreach ($Image->Names->item as $imageName) { if ($imageName->Lang == 'de') { // set the image title in German $image->setDescription($imageName->Name); } } 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(); // set the value for the attribute number $attribute = new \Shopware\Models\Attribute\ArticleImage(); call_user_func(array($attribute, 'setAttribute' . $plenty_attributeID), $Image->Names->item[0]->AlternativeText); $image->setAttribute($attribute); } $image->setPosition($Image->Position); // Generate the thumbnails if (version_compare(Shopware::VERSION, '4.2') != 1) { PlentymarketsImportItemImageThumbnailController::getInstance()->addMediaResource($media); } Shopware()->Models()->persist($image); Shopware()->Models()->flush(); $imageId = $image->getId(); foreach ($shopwareStoreIds as $shopwareStoreId) { // import the image title translations for all active shops of the image $this->importImageTitleTranslation($imageId, $Image->Names->item, $shopwareStoreId); } $plentyId2ShopwareId[$Image->ImageID] = $imageId; $shopwareId2PlentyPosition[$Image->Position] = $imageId; Shopware()->DB()->query(' UPDATE s_articles_img SET articleID = ? WHERE id = ? ', array($this->SHOPWARE_itemId, $imageId)); } } } while (++$Request_GetItemsImages->Page < $Response_GetItemsImages->Pages); if (empty($shopwareId2PlentyPosition)) { return; } ksort($shopwareId2PlentyPosition); $mainImageId = reset($shopwareId2PlentyPosition); if (empty($mainImageId)) { return; } /** * @var Shopware\Models\Article\Image $mainImage */ $mainImage = Shopware()->Models()->find('Shopware\\Models\\Article\\Image', $mainImageId); $mainImage->setMain(1); Shopware()->Models()->persist($mainImage); Shopware()->Models()->flush(); // Get the variant images $Request_GetItemsVariantImages = new PlentySoapRequest_GetItemsVariantImages(); $Request_GetItemsVariantImages->Items = array(); $RequestObject_GetItemsVariantImages = new PlentySoapRequestObject_GetItemsVariantImages(); $RequestObject_GetItemsVariantImages->ItemID = $this->PLENTY_itemId; $Request_GetItemsVariantImages->Items[] = $RequestObject_GetItemsVariantImages; /** * @var PlentySoapResponse_GetItemsVariantImages $Response_GetItemsVariantImages */ $Response_GetItemsVariantImages = PlentymarketsSoapClient::getInstance()->GetItemsVariantImages($Request_GetItemsVariantImages); foreach ($Response_GetItemsVariantImages->Images->item as $GetItemsVariantImagesImage) { try { $shopwareOptionId = PlentymarketsMappingController::getAttributeOptionByPlentyID($GetItemsVariantImagesImage->AttributeValueID); /** * @var \Shopware\Models\Article\Configurator\Option $shopwareOption */ $shopwareOption = Shopware()->Models()->find('Shopware\\Models\\Article\\Configurator\\Option', $shopwareOptionId); } catch (PlentymarketsMappingExceptionNotExistant $e) { continue; } if (!isset($plentyId2ShopwareId[$GetItemsVariantImagesImage->ImageID])) { continue; } /** @var Shopware\Models\Article\Image $shopwareImage */ $shopwareImageId = $plentyId2ShopwareId[$GetItemsVariantImagesImage->ImageID]; /** * @var Image $shopwareImage */ $shopwareImage = Shopware()->Models()->find('Shopware\\Models\\Article\\Image', $shopwareImageId); $mapping = new Shopware\Models\Article\Image\Mapping(); $mapping->setImage($shopwareImage); $rule = new Shopware\Models\Article\Image\Rule(); $rule->setMapping($mapping); $rule->setOption($shopwareOption); $mapping->getRules()->add($rule); $shopwareImage->setMappings($mapping); Shopware()->Models()->persist($mapping); $details = Shopware()->Db()->fetchCol(' SELECT d.id FROM s_articles_details d INNER JOIN s_article_configurator_option_relations alias16 ON alias16.option_id = ' . $shopwareOptionId . ' AND alias16.article_id = d.id WHERE d.articleID = ' . $this->SHOPWARE_itemId . ' '); foreach ($details as $detailId) { /** * Get the detail object * * @var Shopware\Models\Article\Detail $detail */ $detail = Shopware()->Models()->getReference('Shopware\\Models\\Article\\Detail', $detailId); // Create the variant image $variantImage = new Shopware\Models\Article\Image(); $variantImage->setExtension($shopwareImage->getExtension()); $variantImage->setMain($shopwareImage->getMain()); $variantImage->setParent($shopwareImage); $variantImage->setArticleDetail($detail); // And persist it Shopware()->Models()->persist($variantImage); } } Shopware()->Db()->update('s_articles', array('changetime' => date('c', time())), 'id=' . $this->SHOPWARE_itemId); Shopware()->Models()->flush(); }
/** * Genereated the item test SOAP object * * @return PlentySoapObject_ItemTexts[] */ protected function getObjectTexts() { $requestItemTexts = array(); //in this array we save all languages that already have a translation of the article description. $languagesUsed = array(); // if the item is active for a shop => save the item descriptions into the shops languages if (!empty($this->storeIds)) { foreach ($this->storeIds as $storeId => $values) { $mainShopId = PlentymarketsMappingController::getShopByPlentyID($storeId); $shopLanguages = PlentymarketsTranslation::getShopActiveLanguages($mainShopId); foreach ($shopLanguages as $key => $language) { $lang = PlentymarketsTranslation::getPlentyLocaleFormat($language['locale']); if (in_array($lang, $languagesUsed)) { //don't save twice the translation for a language continue; } else { // add the language into the used languages list $languagesUsed[] = $lang; } $Object_ItemTexts = new PlentySoapObject_ItemTexts(); $Object_ItemTexts->Lang = $lang; // string if ($key == key(PlentymarketsTranslation::getShopMainLanguage($mainShopId))) { // set the article texts from the main shop $Object_ItemTexts->Keywords = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getKeywords()); // string $Object_ItemTexts->LongDescription = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getDescriptionLong()); // string $Object_ItemTexts->Name = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getName()); // string $Object_ItemTexts->ShortDescription = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getDescription()); // string } else { // set the article texts from the language shops $translatedText = PlentymarketsTranslation::getShopwareTranslation($mainShopId, 'article', $this->SHOPWARE_Article->getId(), $key); $Object_ItemTexts->Keywords = PlentymarketsSoapClient::removeControlChars($translatedText['txtkeywords']); $Object_ItemTexts->ShortDescription = PlentymarketsSoapClient::removeControlChars($translatedText['txtshortdescription']); $Object_ItemTexts->Name = PlentymarketsSoapClient::removeControlChars($translatedText['txtArtikel']); $Object_ItemTexts->LongDescription = PlentymarketsSoapClient::removeControlChars($translatedText['txtlangbeschreibung']); } $requestItemTexts[] = $Object_ItemTexts; } } } else { // save the item's description per default into German $Object_ItemTexts = new PlentySoapObject_ItemTexts(); $Object_ItemTexts->Lang = 'de'; // string $Object_ItemTexts->Keywords = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getKeywords()); // string $Object_ItemTexts->LongDescription = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getDescriptionLong()); // string $Object_ItemTexts->Name = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getName()); // string $Object_ItemTexts->ShortDescription = PlentymarketsSoapClient::removeControlChars($this->SHOPWARE_Article->getDescription()); // string $requestItemTexts[] = $Object_ItemTexts; } return $requestItemTexts; }
/** * Performs the actual import * * @throws PlentymarketsExportException */ public function run() { // Get the data from plentymarkets (for every mapped shop) $shopIds = Shopware()->Db()->fetchAll(' SELECT * FROM plenty_mapping_shop '); foreach ($shopIds as $shopId) { $mainShopId = PlentymarketsMappingController::getShopByPlentyID($shopId['plentyID']); $mainLang = array_values(PlentymarketsTranslation::getShopMainLanguage($mainShopId)); $Request_GetItemCategoryTree = new PlentySoapRequest_GetItemCategoryTree(); $Request_GetItemCategoryTree->Lang = PlentymarketsTranslation::getPlentyLocaleFormat($mainLang[0]['locale']); $Request_GetItemCategoryTree->GetCategoryNames = true; $Request_GetItemCategoryTree->StoreID = $shopId['plentyID']; $Request_GetItemCategoryTree->GetAktivCategories = true; /** @var PlentySoapResponse_GetItemCategoryTree $Response_GetItemCategoryTree */ $Response_GetItemCategoryTree = PlentymarketsSoapClient::getInstance()->GetItemCategoryTree($Request_GetItemCategoryTree); if (!$Response_GetItemCategoryTree->Success) { Shopware()->Db()->query('INSERT plenty_mapping_category SELECT * FROM plenty_mapping_category_old'); throw new PlentymarketsImportException('The item category tree could not be retrieved', 2920); } /** @var PlentySoapObject_ItemCategoryTreeNode $Category */ foreach ($Response_GetItemCategoryTree->MultishopTree->item[0]->CategoryTree->item as $Category) { $importEntityItemCategoryTree = new PlentymarketsImportEntityItemCategoryTree($Category, $shopId['plentyID'], $Request_GetItemCategoryTree->Lang); $importEntityItemCategoryTree->import(); } } $this->rebuild(); }
/** * Exports the categories * * @param $shopwareCategories * @param $plentyTree * @param $storeId */ private function export($shopwareCategories, $plentyTree, $storeId) { try { $shopId = PlentymarketsMappingController::getShopByPlentyID($storeId); } catch (PlentymarketsMappingExceptionNotExistant $e) { return; } /** @var Shopware\Models\Category\Category $shopwareCategory */ foreach ($shopwareCategories as $shopwareCategory) { if ($shopwareCategory->getBlog()) { continue; } try { PlentymarketsMappingEntityCategory::getCategoryByShopwareID($shopwareCategory->getId(), $shopId); continue; } catch (PlentymarketsMappingExceptionNotExistant $e) { } $branchId = null; if (!isset($plentyTree['children'])) { $plentyTree['children'] = array(); } $shopwareName = trim($shopwareCategory->getName()); /** @var array $plentyChild1 */ foreach ($plentyTree['children'] as $name => $plentyChild1) { if ($name == $shopwareName) { $branchId = $plentyChild1['id']; PlentymarketsMappingEntityCategory::addCategory($shopwareCategory->getId(), $shopId, $branchId, $storeId); break; } } $branchId = $this->exportCategory($shopwareCategory, $storeId, $shopId, $branchId); // Active the category if ($storeId > 0 && $shopwareCategory->getActive()) { $Request_SetStoreCategories = new PlentySoapRequest_SetStoreCategories(); $Request_SetStoreCategories->StoreCategories = array(); $Object_SetStoreCategory = new PlentySoapObject_SetStoreCategory(); $Object_SetStoreCategory->BranchID = $branchId; $Object_SetStoreCategory->StoreID = $storeId; $Request_SetStoreCategories->StoreCategories[] = $Object_SetStoreCategory; PlentymarketsSoapClient::getInstance()->SetStoreCategories($Request_SetStoreCategories); } $shopwareChildren1 = $shopwareCategory->getChildren(); // search for the next categories of shopware in plentymarkets $this->export($shopwareChildren1, $plentyChild1, $storeId); } }
/** * I am the constructor * * @param PlentySoapObject_ItemCategoryTreeNode|PlentySoapObject_ItemCategory $categoryNode * @param integer $storeId * @throws Exception */ public function __construct($categoryNode, $storeId, $categoryNodeLang = 'de') { $category = array(); if (property_exists($categoryNode, 'ItemCategoryPath')) { $categoryPath = explode(';', $categoryNode->ItemCategoryPath); $categoryPathNames = explode(';', $categoryNode->ItemCategoryPathNames); } else { if (property_exists($categoryNode, 'CategoryPath')) { $categoryPath = explode(';', $categoryNode->CategoryPath); $categoryPathNames = explode(';', $categoryNode->CategoryPathNames); } else { throw new Exception(); } } foreach ($categoryPath as $n => $categoryId) { if ($categoryId == 0) { break; } $category[] = array('branchId' => $categoryId, 'name' => $categoryPathNames[$n]); } $this->plentyCategoryBranch = $category; $this->storeId = $storeId; $this->shopId = PlentymarketsMappingController::getShopByPlentyID($storeId); $this->categoryNodeLang = $categoryNodeLang; // get the main language of the shop set it temp $mainLang = array_values(PlentymarketsTranslation::getShopMainLanguage($this->shopId)); $this->shopLang = PlentymarketsTranslation::getPlentyLocaleFormat($mainLang[0]['locale']); if (is_null(self::$CategoryRepository)) { self::$CategoryRepository = Shopware()->Models()->getRepository('Shopware\\Models\\Category\\Category'); } if (is_null(self::$CategoryApi)) { self::$CategoryApi = Shopware\Components\Api\Manager::getResource('Category'); } }
/** * I am the constructor * * @param PlentySoapObject_ItemCategoryTreeNode|PlentySoapObject_ItemCategory $categoryNode * @param integer $storeId * @throws Exception */ public function __construct($categoryNode, $storeId) { $category = array(); if (property_exists($categoryNode, 'ItemCategoryPath')) { $categoryPath = explode(';', $categoryNode->ItemCategoryPath); $categoryPathNames = explode(';', $categoryNode->ItemCategoryPathNames); } else { if (property_exists($categoryNode, 'CategoryPath')) { $categoryPath = explode(';', $categoryNode->CategoryPath); $categoryPathNames = explode(';', $categoryNode->CategoryPathNames); } else { throw new Exception(); } } foreach ($categoryPath as $n => $categoryId) { if ($categoryId == 0) { break; } $category[] = array('branchId' => $categoryId, 'name' => $categoryPathNames[$n]); } $this->plentyCategoryBranch = $category; $this->storeId = $storeId; $this->shopId = PlentymarketsMappingController::getShopByPlentyID($storeId); if (is_null(self::$CategoryRepository)) { self::$CategoryRepository = Shopware()->Models()->getRepository('Shopware\\Models\\Category\\Category'); } if (is_null(self::$CategoryApi)) { self::$CategoryApi = Shopware\Components\Api\Manager::getResource('Category'); } }