/** * Init stopword model * * @return \Mirasvit\Search\Model\Stopword */ protected function initModel() { $model = $this->stopwordFactory->create(); if ($this->getRequest()->getParam('id')) { $model->load($this->getRequest()->getParam('id')); } $this->registry->register('current_model', $model); return $model; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('remove')) { $store = $input->getOption('store'); $collection = $this->stopwordFactory->create()->getCollection(); if ($store) { $collection->addFieldToFilter('store_id', $store); } $cnt = 0; foreach ($collection as $item) { $item->delete(); $cnt++; if ($cnt % 1000 == 0) { $output->writeln("<info>{$cnt} stopwords are removed...</info>"); } } $output->writeln("<info>{$cnt} stopwords are removed.</info>"); return; } if ($input->getOption('file') && $input->getOption('store')) { $file = $this->config->getStopwordDirectoryPath() . DIRECTORY_SEPARATOR . $input->getOption('file'); $store = $input->getOption('store'); $result = $this->stopwordFactory->create()->import($file, $store); $output->writeln("<info>Imported {$result['stopwords']} stopwords</info>"); } else { $output->writeln('<info>Available files:</info>'); foreach ($this->stopwordFactory->create()->getAvailableFiles() as $file) { $info = pathinfo($file); $output->writeln(" {$info['basename']}"); } $output->writeln('<info>Available stores:</info>'); foreach ($this->storeManager->getStores(true) as $store) { $output->writeln(" {$store->getId()} [{$store->getCode()}]"); } } }