setName('customdimensions:info');
$this->setDescription('Get information about currently installed Custom Dimensions');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
foreach (CustomDimensions::getScopes() as $scope) {
$tracking = new LogTable($scope);
$output->writeln(sprintf('%s Custom Dimensions available in scope "%s"', $tracking->getNumInstalledIndexes(), $scope));
if ($scope === CustomDimensions::SCOPE_CONVERSION) {
$output->writeln(sprintf('Custom Dimensions are automatically added via the scope "%s" and cannot be added manually', CustomDimensions::SCOPE_VISIT));
} else {
$output->writeln(sprintf('To add a Custom Dimension execute "./console customdimensions:add-custom-dimension --scope=%s"', $scope));
}
$output->writeln('Installed indexes are:');
foreach ($tracking->getInstalledIndexes() as $index) {
$output->writeln(sprintf('%d to remove this Custom Dimension execute ./console customdimensions:remove-custom-dimension --scope=%s --index=%d', $index, $scope, $index));
}
$output->writeln('');
}
$visit = new LogTable(CustomDimensions::SCOPE_VISIT);
$numVisit = $visit->getNumInstalledIndexes();
$conversion = new LogTable(CustomDimensions::SCOPE_CONVERSION);
$numConversions = $conversion->getNumInstalledIndexes();
if ($numConversions < $numVisit) {
$output->writeln('');
$output->writeln('We found an error, Custom Dimensions in scope "conversion" are not correctly installed. Execute the following command to repair it:');
$output->writeln(sprintf('./console customdimensions:add-custom-dimension --scope=%s --count=%d', CustomDimensions::SCOPE_CONVERSION, $numVisit - $numConversions));
}
}
}