For Wordpress-Multisites with "Matomo for WordPress", each site has a different database table prefix (like wp_matomo_, wp_2_matomo_, ...).
For each table wp_X_matomo_site, there is one single entry (therefore Matomo's idsite is always 1 for each multisite site)
Therefore it is not possible to migrate other than the main site of the multisite, because idsite 2 etc. is not found.
A quick-and-dirty workaround is, to replace the database table prefix, for example with an additional parameter in Commands/Migrate.php:configure():
$this->addRequiredValueOption('source-wpsite', null, 'Source Multisite Site ID you want to migrate');
and add in Commands/Migrate.php:doExecute():
$multiSiteId = (int) $input->getOption('source-wpsite');
if($multiSiteId != 1) {
\Piwik\Config::getInstance()->database['tables_prefix'] = str_replace("wp_", "wp_" . $multiSiteId . "_", \Piwik\Config::getInstance()->database['tables_prefix']);
}
Warning: Keep in mind, that this snippet is for demonstration only. The table-prefix might not be "wp_", because it is configurable as well. Also it might be the optimal place and/or way to fix that behavior, as I'm currently not too familiar with Matomo's codebase
For Wordpress-Multisites with "Matomo for WordPress", each site has a different database table prefix (like wp_matomo_, wp_2_matomo_, ...).
For each table wp_X_matomo_site, there is one single entry (therefore Matomo's idsite is always 1 for each multisite site)
Therefore it is not possible to migrate other than the main site of the multisite, because idsite 2 etc. is not found.
A quick-and-dirty workaround is, to replace the database table prefix, for example with an additional parameter in Commands/Migrate.php:configure():
and add in Commands/Migrate.php:doExecute():
Warning: Keep in mind, that this snippet is for demonstration only. The table-prefix might not be "wp_", because it is configurable as well. Also it might be the optimal place and/or way to fix that behavior, as I'm currently not too familiar with Matomo's codebase