rebuildCategoryPath example



    public function rebuildCategoryPathAction()
    {
        // Try to set maximum execution time         @set_time_limit(0);

        $categoryId = $this->Request()->getParam('categoryId');
        $offset = (int) $this->Request()->getParam('offset');
        $count = $this->Request()->getParam('limit');

        $this->getCategoryComponent()->rebuildCategoryPath($categoryId$count$offset);

        $this->view->assign([
            'success' => true,
        ]);
    }

    public function getRemoveOldAssignmentsCountAction()
    {
        $categoryId = $this->Request()->getParam('categoryId');

        $count = $this->getCategoryComponent()->removeOldAssignmentsCount($categoryId);

        
/** * Fixes category tree */
    public function fixCategoriesAction()
    {
        $offset = (int) $this->Request()->getParam('offset', 0);
        $limit = (int) $this->Request()->getParam('limit');

        $component = Shopware()->Container()->get('categorydenormalization');

        if ($offset === 0) {
            $component->rebuildCategoryPath();
            $component->removeAllAssignments();
        }

        $count = $component->rebuildAllAssignments($limit$offset);

        $this->View()->assign([
            'success' => true,
            'total' => $count,
        ]);
    }

    
$progress = (int) $input->getOption('offset');
        $limit = $input->getOption('limit') ?: 1000;

        /** @var CategoryDenormalization $component */
        $component = Shopware()->Container()->get('categorydenormalization');

        // Cleanup before the first call         if ($progress === 0) {
            $output->writeln('Removing orphans');
            $component->removeOrphanedAssignments();
            $output->writeln('Rebuild path info');
            $component->rebuildCategoryPath();
            $output->writeln('Removing assignments');
            $component->removeAllAssignments();
        }

        // Get total number of assignments to build         $output->write('Counting…');
        $count = $component->rebuildAllAssignmentsCount();
        $output->writeln("\rCounted {$count} items");

        $progressHelper = new ProgressBar($output$count);
        $progressHelper->setFormat(' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%');

        

        $this->getCategoryComponent()->removeCategoryAssignmentments($categoryId);
    }

    /** * @param int $categoryId */
    public function backlogMoveCategory($categoryId)
    {
        $component = $this->getCategoryComponent();

        $component->rebuildCategoryPath($categoryId);
        $component->removeOldAssignments($categoryId);
        $component->rebuildAssignments($categoryId);
    }

    protected function addPendingAddAssignment(Article $article, Category $category)
    {
        $this->pendingAddAssignments[$category->getId() . '_' . $article->getId()] = [
            'category' => $category,
            'article' => $article,
        ];
    }

    
Home | Imprint | This part of the site doesn't use cookies.