We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Would help with keeping the files section clean and keeping the number of assets down
The text was updated successfully, but these errors were encountered:
possibly a good example: https://github.com/xddesigners/silverstripe-shopify/blob/master/src/Task/Import.php
Sorry, something went wrong.
could be done like the following. The only issue doing it this way is if the image is related to a non-salsify object.
/** * @param $file * @param bool $multiple */ public function onAfterMap($file, $multiple) { if ($multiple == Mapper::$SINGLE) { return; } // Images and Files $this->owner->resetAssetStream(); $assetStream = $this->owner->getAssetStream(); $this->archiveUnused($assetStream, File::class, 'assets', true); } /** * @param JsonMachine $stream * @param string|DataObject $class * @param string $typeName * @param bool $excludeNull If things with a null salsify ID should be archived */ private function archiveUnused($stream, $class, $typeName, $excludeNull = false) { $codes = []; if ($excludeNull) { $codes[] = null; } foreach ($this->owner->yieldKeyVal($stream) as $name => $data) { $codes[] = $data['salsify:id']; } $invalidObjects = $class::get()->exclude([ 'SalsifyID' => $codes, ]); $count = 0; foreach ($this->owner->yieldSingle($invalidObjects) as $invalid) { /** @var File $invalidProduct */ $invalid->doArchive(); $count++; } ImportTask::output("Archived {$count} {$typeName}."); }
No branches or pull requests
Would help with keeping the files section clean and keeping the number of assets down
The text was updated successfully, but these errors were encountered: