+namespace Namespace\To\Out\Plugin;
+use Vendor\Extension\Model\Config as ModuleConfig;
+use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\App\ProductMetadata;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Registry as CoreRegistry;
+use Magento\Framework\View\Design\ThemeInterface;
+use Magento\Framework\View\Layout\File\Collector\Aggregated;
+ * Core registry object.
+ protected $coreRegistry;
+ * Product meta data object.
+ protected $productMetadata;
+ * @param CoreRegistry $coreRegistry Core registry object.
+ * @param Filesystem $filesystem File system object.
+ * @param ProductMetadata $productMetadata Product meta data object.
+ public function __construct(
+ CoreRegistry $coreRegistry,
+ Filesystem $filesystem,
+ ProductMetadata $productMetadata
+ $this->coreRegistry = $coreRegistry;
+ $this->filesystem = $filesystem;
+ $this->productMetadata = $productMetadata;
+ * Plugin for getFiles method. Get order archive layout update file index
+ * and save it in registry to be able to recognize it in further processing.
+ * It will be applied for magento version lower than 2.1.
+ * @param Aggregated $subject Subject object.
+ * @param Closure $proceed Closure object.
+ * @param ThemeInterface $theme Theme object.
+ * @param string $filePath File path.
+ public function aroundGetFiles(
+ $files = $proceed($theme, $filePath);
+ if ($filePath !== 'sales_order_grid.xml') {
+ $version = $this->productMetadata->getVersion();
+ if (version_compare($version, '2.1') >= 0) {
+ $fileReader = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);
+ foreach ($files as $index => $file) {
+ if ($file->getModule() !== 'Vendor_Extension') {
+ $filePath = $fileReader->getRelativePath($file->getFilename());
+ $fileKey = sprintf('%x', crc32($filePath));
+ $this->coreRegistry->register(
+ ModuleConfig::REGISTRY_SALES_ORDER_GRID_FILE_INDEX,