Skip to content

Commit

Permalink
Merge pull request #22 from DivanteLtd/feature/specify-object-ids
Browse files Browse the repository at this point in the history
Specify object IDs
  • Loading branch information
t-zilla authored Nov 20, 2020
2 parents 7f26ae6 + 1e1183f commit 60faec7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/ScheduledExportBundle/Command/ScheduledExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ protected function configure()
'',
InputOption::VALUE_OPTIONAL,
'Set what types should be exported; e. g. "object,variant"; defaults to default list settings'
)->addOption(
'object-ids',
'',
InputOption::VALUE_OPTIONAL,
'Export only specified object ids'
)
;
}
Expand Down
11 changes: 9 additions & 2 deletions src/ScheduledExportBundle/Export/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,15 @@ public function export(): void
{
$this->process->setStatus(ProcessManagerBundle::STATUS_RUNNING);
$this->process->save();
$this->prepareListing();
$objectIds = $this->getObjectIds();

if ($this->input->getOption('object-ids')) {
$objectIds = explode(',', $this->input->getOption('object-ids'));
$objectIds = array_map('intval', $objectIds);
$objectIds = array_chunk($objectIds, self::INTERNAL_BATCH_SIZE);
} else {
$this->prepareListing();
$objectIds = $this->getObjectIds();
}
$filenames = [];

$this->process->setMessage("Starting");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ public function run(ExecutableInterface $executable, ?array $params = null)
{
$settings = $executable->getSettings();

if (is_array($params)) {
$settings = array_merge($settings, $params);
}

$command = sprintf(
'scheduled-export:start -g %s -f %s -a %s --filename %s -t %s --format %s'
. ' -c %s --only-changes %s --delimiter %s --divide_file %s --preserve_process %s --types %s',
. ' -c %s --only-changes %s --delimiter %s --divide_file %s --preserve_process %s --types %s'
. ' --object-ids %s',
escapeshellarg($settings['grid_config']),
escapeshellarg($settings['objects_folder']),
escapeshellarg($settings['asset_folder']),
Expand All @@ -43,7 +48,8 @@ public function run(ExecutableInterface $executable, ?array $params = null)
escapeshellarg($settings['delimiter']),
escapeshellarg($settings['divide_file']),
escapeshellarg($settings['preserve_process']),
escapeshellarg($settings['types'])
escapeshellarg($settings['types']),
escapeshellarg($settings['object_ids'] ?? '')
);

$command = PIMCORE_PROJECT_ROOT . "/bin/console " . $command;
Expand Down

0 comments on commit 60faec7

Please sign in to comment.