Skip to content

Commit

Permalink
Merge pull request #53 from Scarbous/patch-2
Browse files Browse the repository at this point in the history
[Bugfix] type error without option -s
  • Loading branch information
peterjaap authored Feb 9, 2022
2 parents 1dac64d + cf52667 commit abc0098
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,29 @@ public function execute(InputInterface $input, OutputInterface $output)

$storeId = $input->getOption('store');

$stores = $this->storeManager->getStores(false);

if (!is_numeric($storeId)) {
if (!is_null($storeId) && !is_numeric($storeId)) {
$storeId = $this->getStoreIdByCode($storeId, $stores);
}

$this->regenerateProductUrl->setOutput($output);
$this->regenerateProductUrl->execute($input->getArgument('pids'), (int) $storeId, $output->isVerbose());
$this->regenerateProductUrl->execute($input->getArgument('pids'), $storeId, $output->isVerbose());
}

/**
* @param string $storeId
* @param StoreInterface[] $stores
* @param string $storeId
*
* @return bool|int
* @return null|int
*/
private function getStoreIdByCode(string $storeId, array $stores)
private function getStoreIdByCode(string $storeId):?int
{
$stores = $this->storeManager->getStores(false);

foreach ($stores as $store) {
if ($store->getCode() == $storeId) {
return $store->getId();
return (int)$store->getId();
}
}

return false;
return null;
}
}

0 comments on commit abc0098

Please sign in to comment.