Skip to content

Commit

Permalink
NavigationPro installation improved: activate existing menu
Browse files Browse the repository at this point in the history
  • Loading branch information
vovayatsyuk committed Mar 29, 2019
1 parent 0fe4d62 commit 0b11af8
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions Model/Module/UpgradeCommands/Navigationpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function execute($data)
->create()
->load($name, 'identifier');

// don't do anything if menu with the same identifier is already exists
if ($menu->getId()) {
$this->activate($menu, $storeIds);
continue;
}

Expand All @@ -75,11 +75,7 @@ public function execute($data)
$menu = $builder->save();

if (!empty($menuData['activate'])) {
$this->saveConfig(
'navigationpro/top/identifier',
$menu->getIdentifier(),
$storeIds
);
$this->activate($menu, $storeIds);
}
} catch (\Exception $e) {
$this->fault('navigationpro_menu_save', $e);
Expand All @@ -88,4 +84,19 @@ public function execute($data)
}
}
}

/**
* Activate menu per store ids
*
* @param \Swissup\Navigationpro\Model\Menu $menu
* @param array $storeIds
*/
private function activate(\Swissup\Navigationpro\Model\Menu $menu, $storeIds)
{
$this->saveConfig(
'navigationpro/top/identifier',
$menu->getIdentifier(),
$storeIds
);
}
}

0 comments on commit 0b11af8

Please sign in to comment.