Пример #1
0
 /**
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNode
  *
  * @return void
  */
 public function update(NodeTransfer $categoryNode)
 {
     $nodeEntity = $this->queryContainer->queryNodeById($categoryNode->getIdCategoryNode())->findOne();
     if ($nodeEntity) {
         $nodeEntity->fromArray($categoryNode->toArray());
         $nodeEntity->save();
     }
 }
 /**
  * @param \Orm\Zed\Category\Persistence\SpyCategoryNode $node
  *
  * @return string
  */
 protected function buildPath(SpyCategoryNode $node)
 {
     $pathTokens = $this->categoryQueryContainer->queryPath($node->getIdCategoryNode(), $this->locale->getIdLocale(), false, true)->find();
     $formattedPath = [];
     foreach ($pathTokens as $path) {
         $formattedPath[] = $path['name'];
     }
     return '/' . implode('/', $formattedPath);
 }
Пример #3
0
 /**
  * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config
  *
  * @return array
  */
 protected function prepareData(TableConfiguration $config)
 {
     $query = $this->categoryQueryContainer->queryRootNodes()->orderBy(SpyCategoryAttributeTableMap::COL_NAME)->setModelAlias('spy_locale')->filterByFkLocale($this->idLocale);
     $queryResults = $this->runQuery($query, $config);
     $results = [];
     foreach ($queryResults as $rootNode) {
         $results[] = [SpyCategoryAttributeTableMap::COL_FK_CATEGORY => $rootNode[SpyCategoryAttributeTableMap::COL_FK_CATEGORY], SpyCategoryAttributeTableMap::COL_NAME => $rootNode[SpyCategoryAttributeTableMap::COL_NAME], SpyLocaleTableMap::COL_LOCALE_NAME => $rootNode[self::LOCALE_NAME], self::COL_REORDER => implode(' ', $this->createActionButtons($rootNode))];
     }
     unset($queryResults);
     return $results;
 }
Пример #4
0
 /**
  * @param \Orm\Zed\Category\Persistence\SpyCategoryNode $node
  *
  * @return void
  */
 protected function addClosureConnections(SpyCategoryNode $node)
 {
     $descendantPaths = $this->queryContainer->queryDescendant($node->getPrimaryKey())->find();
     foreach ($descendantPaths as $path) {
         $attributes = ['color' => '#ff0000'];
         $this->graph->addEdge($this->getNodeHash($node), $this->getNodeHash($path->getDescendantNode()), $attributes);
     }
 }
Пример #5
0
 /**
  * @param \Generated\Shared\Transfer\NodeTransfer $categoryNode
  *
  * @return void
  */
 public function moveNode(NodeTransfer $categoryNode)
 {
     $obsoleteEntities = $this->queryContainer->queryClosureTableParentEntries($categoryNode->getIdCategoryNode())->find();
     foreach ($obsoleteEntities as $obsoleteEntity) {
         $obsoleteEntity->delete();
     }
     $nodeEntities = $this->queryContainer->queryClosureTableFilterByIdNode($categoryNode->getIdCategoryNode())->find();
     $parentEntities = $this->queryContainer->queryClosureTableFilterByIdNodeDescendant($categoryNode->getFkParentCategoryNode())->find();
     foreach ($nodeEntities as $nodeEntity) {
         foreach ($parentEntities as $parentEntity) {
             $depth = $nodeEntity->getDepth() + $parentEntity->getDepth() + 1;
             $closureTableEntity = new SpyCategoryClosureTable();
             $closureTableEntity->setFkCategoryNode($parentEntity->getFkCategoryNode());
             $closureTableEntity->setFkCategoryNodeDescendant($nodeEntity->getFkCategoryNodeDescendant());
             $closureTableEntity->setDepth($depth);
             $closureTableEntity->save();
         }
     }
 }
 /**
  * @param \Propel\Runtime\ActiveQuery\ModelCriteria $expandableQuery
  * @param bool $excludeDirectParent
  * @param bool $excludeRoot
  *
  * @return \Propel\Runtime\ActiveQuery\ModelCriteria
  */
 public function expandQuery(ModelCriteria $expandableQuery, $excludeDirectParent = true, $excludeRoot = true)
 {
     $expandableQuery->addJoin(SpyTouchTableMap::COL_ITEM_ID, SpyProductCategoryTableMap::COL_FK_PRODUCT_ABSTRACT, Criteria::LEFT_JOIN);
     $expandableQuery->addJoin(SpyProductCategoryTableMap::COL_FK_CATEGORY_NODE, SpyCategoryNodeTableMap::COL_ID_CATEGORY_NODE, Criteria::INNER_JOIN);
     $expandableQuery->addJoin(SpyCategoryNodeTableMap::COL_FK_CATEGORY, SpyCategoryAttributeTableMap::COL_FK_CATEGORY, Criteria::INNER_JOIN);
     $expandableQuery = $this->categoryQueryContainer->joinCategoryQueryWithUrls($expandableQuery);
     $expandableQuery = $this->categoryQueryContainer->selectCategoryAttributeColumns($expandableQuery);
     $expandableQuery = $this->categoryQueryContainer->joinCategoryQueryWithChildrenCategories($expandableQuery);
     $expandableQuery = $this->categoryQueryContainer->joinLocalizedRelatedCategoryQueryWithAttributes($expandableQuery, 'categoryChildren', 'child');
     $expandableQuery = $this->categoryQueryContainer->joinRelatedCategoryQueryWithUrls($expandableQuery, 'categoryChildren', 'child');
     $expandableQuery = $this->categoryQueryContainer->joinCategoryQueryWithParentCategories($expandableQuery, $excludeDirectParent, $excludeRoot);
     $expandableQuery = $this->categoryQueryContainer->joinLocalizedRelatedCategoryQueryWithAttributes($expandableQuery, 'categoryParents', 'parent');
     $expandableQuery = $this->categoryQueryContainer->joinRelatedCategoryQueryWithUrls($expandableQuery, 'categoryParents', 'parent');
     $expandableQuery->withColumn('GROUP_CONCAT(DISTINCT spy_category_node.id_category_node)', 'node_id');
     $expandableQuery->withColumn(SpyCategoryNodeTableMap::COL_FK_CATEGORY, 'category_id');
     $expandableQuery->orderBy('depth', Criteria::DESC);
     $expandableQuery->orderBy('descendant_id', Criteria::DESC);
     $expandableQuery->groupBy('abstract_sku');
     return $expandableQuery;
 }
 /**
  * @param int $idCategory
  * @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer
  *
  * @return void
  */
 public function deleteCategoryRecursive($idCategory, LocaleTransfer $localeTransfer)
 {
     $this->connection->beginTransaction();
     $this->removeMappings($idCategory);
     $categoryNodes = $this->categoryQueryContainer->queryAllNodesByCategoryId($idCategory)->find();
     foreach ($categoryNodes as $node) {
         $this->cmsFacade->updateBlocksAssignedToDeletedCategoryNode($node->getIdCategoryNode());
         //TODO: https://spryker.atlassian.net/browse/CD-540
         $children = $this->categoryQueryContainer->queryFirstLevelChildren($node->getIdCategoryNode())->find();
         foreach ($children as $child) {
             $this->deleteCategoryRecursive($child->getFkCategory(), $localeTransfer);
         }
         $nodeExists = $this->categoryQueryContainer->queryNodeById($node->getIdCategoryNode())->count() > 0;
         if ($nodeExists) {
             $this->categoryFacade->deleteNode($node->getIdCategoryNode(), $localeTransfer, true);
         }
     }
     $this->categoryFacade->deleteCategory($idCategory);
     $this->connection->commit();
 }
Пример #8
0
 /**
  * @param int $idCategory
  *
  * @return \Orm\Zed\Category\Persistence\SpyCategory
  */
 protected function getCategoryEntity($idCategory)
 {
     return $this->queryContainer->queryCategoryById($idCategory)->findOne();
 }
Пример #9
0
 /**
  * @param int $idParentNode
  * @param int $idLocale
  *
  * @return \Orm\Zed\Category\Persistence\SpyCategoryNode[]|\Propel\Runtime\Collection\ObjectCollection
  */
 public function getCategoryNodesWithOrder($idParentNode, $idLocale)
 {
     return $this->queryContainer->getCategoryNodesWithOrder($idParentNode, $idLocale)->find();
 }