Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Service/Menu/Cloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Exception;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Serialize\SerializerInterface;
use Snowdog\Menu\Api\Data\MenuInterface;
use Snowdog\Menu\Api\Data\MenuInterfaceFactory;
use Snowdog\Menu\Api\Data\NodeInterfaceFactory;
Expand Down Expand Up @@ -57,6 +58,11 @@ class Cloner
*/
private $menuNodes;

/**
* @var SerializerInterface
*/
private $serializer;

public function __construct(
ResourceConnection $resource,
MenuInterfaceFactory $menuFactory,
Expand All @@ -65,7 +71,8 @@ public function __construct(
NodeRepositoryInterface $nodeRepository,
MenuIdentifierProcessor $menuIdentifierProcessor,
NodeTypeProvider $nodeTypeProvider,
MenuNodes $menuNodes
MenuNodes $menuNodes,
SerializerInterface $serializer
) {
$this->resource = $resource;
$this->menuFactory = $menuFactory;
Expand All @@ -75,6 +82,7 @@ public function __construct(
$this->menuIdentifierProcessor = $menuIdentifierProcessor;
$this->nodeTypeProvider = $nodeTypeProvider;
$this->menuNodes = $menuNodes;
$this->serializer = $serializer;
}

/**
Expand Down Expand Up @@ -103,8 +111,13 @@ public function clone(MenuInterface $menu): MenuInterface

foreach ($this->menuNodes->getList($menu) as $node) {
$nodeClone = $this->nodeFactory->create();
$data = $node->getData();

if (isset($data['customer_groups'])) {
$data['customer_groups'] = $this->serializer->serialize((array) $data['customer_groups']);
}

$nodeClone->setData($node->getData());
$nodeClone->setData($data);
$nodeClone->setId(null);
$nodeClone->setMenuId($menuCloneId);

Expand Down
Loading