<?php

require_once 'Upgrade.php';

use ComPixelCMS\MenuItem;
use ComPixelCMS\Upgrade;

class upgrade_3_12_0 extends Upgrade
{
    public function run()
    {
        $links = $this->getMenuItemsFiltered([
            'manufacturer_link_ids'
        ]);

        foreach ($links as $link) {
            $manufacturer_ids = $link->link['manufacturer_link_ids'];
            unset($link->link['manufacturer_link_ids']);

            $link->link['m_ids'] = $manufacturer_ids;

            $link->save();
        }

        if (!empty($links)) {
            $this->msg('Hersteller IDs optimiert', 'success');
        }
    }
}
