Closed zfmaster closed 10 months ago
.../web/vendor/olegkoval/magento2-regenerate-url-rewrites/Console/Command/RegenerateUrlRewrites.php
SOLUTION working for me
` /**
@return void */ protected function execute(InputInterface $input, OutputInterface $output) { set_time_limit(0); $this->_input = $input; $this->_output = $output;
$this->_output->writeln('Regenerating of URL rewrites:');
$this->_showSupportMe();
$this->getCommandOptions();
if (count($this->_errors) > 0) {
foreach ($this->_errors as $error) {
$this->_addConsoleMsg($error);
}
return 1;
}
// set area code if needed
try {
$areaCode = $this->_appState->getAreaCode();
} catch (\Magento\Framework\Exception\LocalizedException $e) {
// if area code is not set then magento generate exception "LocalizedException"
$this->_appState->setAreaCode('adminhtml');
}
foreach ($this->_commandOptions['storesList'] as $storeId => $storeCode) {
$this->_output->writeln('');
$this->_output->writeln("[Type: {$this->_commandOptions['entityType']}, Store ID: {$storeId}, Store View code: {$storeCode}]:");
$this->_storeManager->setCurrentStore($storeId);
if ($this->_commandOptions['entityType'] == self::INPUT_KEY_REGENERATE_ENTITY_TYPE_PRODUCT) {
$this->regenerateProductRewrites->regenerateOptions = $this->_commandOptions;
$this->regenerateProductRewrites->regenerate($storeId);
} elseif ($this->_commandOptions['entityType'] == self::INPUT_KEY_REGENERATE_ENTITY_TYPE_CATEGORY) {
$this->regenerateCategoryRewrites->regenerateOptions = $this->_commandOptions;
$this->regenerateCategoryRewrites->regenerate($storeId);
}
}
$this->_output->writeln('');
$this->_output->writeln('');
$this->_displayConsoleMsg();
$this->_runReindexation();
$this->_runClearCache();
$this->_showSupportMe();
$this->_output->writeln('Finished');
return 0;
}`
@gotanasro3 you should not use 1 or 0. Check my PR - the right way is to use constants: Command::FAILURE, Command::SUCCESS.
@gotanasro3 you should not use 1 or 0. Check my PR - the right way is to use constants: Command::FAILURE, Command::SUCCESS.
thanks you
this error
There is an error in .../web/vendor/symfony/console/Command/Command.php at line: 301 Return value of "OlegKoval\RegenerateUrlRewrites\Console\Command\RegenerateUrlRewrites\Interceptor::execute()" must be of the type int, "null" returned.#0 .../web/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run()
1 .../web/vendor/magento/framework/Interception/Interceptor.php(138): OlegKoval\RegenerateUrlRewrites\Console\Command\RegenerateUrlRewrites\Interceptor->___callParent()
2 .../web/vendor/magento/framework/Interception/Interceptor.php(153): OlegKoval\RegenerateUrlRewrites\Console\Command\RegenerateUrlRewrites\Interceptor->Magento\Framework\Interception{closure}()
3 .../web/generated/code/OlegKoval/RegenerateUrlRewrites/Console/Command/RegenerateUrlRewrites/Interceptor.php(23): OlegKoval\RegenerateUrlRewrites\Console\Command\RegenerateUrlRewrites\Interceptor->___callPlugins()
4 .../web/vendor/symfony/console/Application.php(1040): OlegKoval\RegenerateUrlRewrites\Console\Command\RegenerateUrlRewrites\Interceptor->run()
5 .../web/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
6 ..../web/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun()
7 .../web/vendor/symfony/console/Application.php(171): Magento\Framework\Console\Cli->doRun()
8 .../web/bin/magento(23): Symfony\Component\Console\Application->run()
9 {main}