removeOrphanedAssignments example

protected function execute(InputInterface $input, OutputInterface $output)
    {
        $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");

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

    public function prepareTreeAction()
    {
        $component = Shopware()->Container()->get('categorydenormalization');

        $component->removeOrphanedAssignments();

        $count = $component->rebuildAllAssignmentsCount();

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

    /** * Calculates the number of all urls to create a cache entry for */
Home | Imprint | This part of the site doesn't use cookies.