コード例 #1
0
ファイル: sRewriteTable.php プロジェクト: nhp/shopware-4
 protected function sCreateRewriteTableCategories()
 {
     if (empty($this->sSYSTEM->sCONFIG['sROUTERCATEGORYTEMPLATE'])) {
         return;
     }
     $parentId = $this->baseCategory->getId();
     $result = $this->repository->getActiveChildrenByIdQuery($parentId)->getArrayResult();
     $categories = array();
     foreach ($result as $category) {
         $categories[$category['category']['id']] = array_merge($category['category'], array('description' => $category['category']['name'], 'childrenCount' => $category['childrenCount'], 'articleCount' => $category['articleCount']));
     }
     foreach ($categories as $category) {
         if (!empty($category['external'])) {
             continue;
         }
         $this->data->assign('sCategory', $category);
         $path = $this->template->fetch('string:' . $this->sSYSTEM->sCONFIG['sROUTERCATEGORYTEMPLATE'], $this->data);
         $path = $this->sCleanupPath($path, false);
         if ($category['blog']) {
             $orgPath = 'sViewport=blog&sCategory=' . $category['id'];
         } else {
             $orgPath = 'sViewport=cat&sCategory=' . $category['id'];
         }
         $this->sInsertUrl($orgPath, $path);
     }
 }
 /**
  * Creates the category in plentymarkets
  *
  * @param \Shopware\Models\Category\Category $category
  * @param $storeId
  * @param $shopId
  * @param null $categoryId
  * @return int|null
  * @throws PlentymarketsExportException
  */
 private function exportCategory(Shopware\Models\Category\Category $category, $storeId, $shopId, $categoryId = null)
 {
     $level = $category->getLevel() - 1;
     if ($level == 1) {
         $parentId = null;
     } else {
         $parentId = PlentymarketsMappingEntityCategory::getCategoryByShopwareID($category->getParentId(), $shopId);
     }
     $Request_SetCategories = new PlentySoapRequest_SetCategories();
     $Request_SetCategories->SetCategories = array();
     $RequestObject_SetCategories = new PlentySoapRequestObject_SetCategories();
     $RequestObject_SetCategories->CategoryID = $categoryId;
     $RequestObject_CreateCategory = new PlentySoapRequestObject_CreateCategory();
     $RequestObject_CreateCategory->Description = null;
     // string
     $RequestObject_CreateCategory->Description2 = null;
     // string
     $RequestObject_CreateCategory->FulltextActive = null;
     // string
     $RequestObject_CreateCategory->Image = null;
     // string
     $RequestObject_CreateCategory->Image1Path = null;
     // string
     $RequestObject_CreateCategory->Image2 = null;
     // string
     $RequestObject_CreateCategory->Image2Path = null;
     // string
     $RequestObject_CreateCategory->ItemListView = null;
     // string
     $RequestObject_CreateCategory->Lang = 'de';
     // string
     $RequestObject_CreateCategory->Level = $level;
     // int
     $RequestObject_CreateCategory->MetaDescription = $category->getMetaDescription();
     // string
     $RequestObject_CreateCategory->MetaKeywords = $category->getMetaKeywords();
     // string
     $RequestObject_CreateCategory->MetaTitle = $category->getName();
     // string
     $RequestObject_CreateCategory->Name = $category->getName() ?: 'Category ' . $category->getId();
     // string
     $RequestObject_CreateCategory->NameURL = null;
     // string
     $RequestObject_CreateCategory->PageView = null;
     // string
     $RequestObject_CreateCategory->PlaceholderTranslation = null;
     // string
     $RequestObject_CreateCategory->Position = $category->getPosition();
     // int
     $RequestObject_CreateCategory->PreviewPath = null;
     // string
     $RequestObject_CreateCategory->RootPath = null;
     // string
     $RequestObject_CreateCategory->ShortDescription = null;
     // string
     $RequestObject_CreateCategory->SingleItemView = null;
     // string
     $RequestObject_CreateCategory->WebTemplateExist = null;
     // string
     $RequestObject_CreateCategory->WebstoreID = $storeId;
     // int
     $RequestObject_CreateCategory->ParentCategoryID = $parentId;
     //int
     $RequestObject_SetCategories->CreateCategory = $RequestObject_CreateCategory;
     $Request_SetCategories->SetCategories[] = $RequestObject_SetCategories;
     $Response_SetCategories = PlentymarketsSoapClient::getInstance()->SetCategories($Request_SetCategories);
     if (!$Response_SetCategories->Success) {
         throw new PlentymarketsExportException('The category could not be saved! ', 2920);
     } else {
         $categoryId = (int) $Response_SetCategories->Categories->item[0]->CategoryID;
         $shopId = PlentymarketsMappingController::getShopByPlentyID($storeId);
         PlentymarketsMappingEntityCategory::addCategory($category->getId(), $shopId, $categoryId, $storeId);
         return $categoryId;
     }
 }