diff --git a/Api/ContentInterface.php b/Api/ContentInterface.php index ee53c4e..9088fc3 100644 --- a/Api/ContentInterface.php +++ b/Api/ContentInterface.php @@ -25,7 +25,8 @@ * @package MSP\CmsImportExport\Api * @api */ -interface ContentInterface { +interface ContentInterface +{ const CMS_MODE_UPDATE = 'update'; const CMS_MODE_SKIP = 'skip'; diff --git a/Block/Adminhtml/Import.php b/Block/Adminhtml/Import.php index 80faa71..ecfda31 100644 --- a/Block/Adminhtml/Import.php +++ b/Block/Adminhtml/Import.php @@ -22,7 +22,8 @@ use Magento\Backend\Block\Widget\Form\Container; -class Import extends Container { +class Import extends Container +{ protected $_mode = 'upload'; protected function _construct() diff --git a/Model/Content.php b/Model/Content.php index 3bd5e00..beeef13 100644 --- a/Model/Content.php +++ b/Model/Content.php @@ -34,7 +34,6 @@ use MSP\CmsImportExport\Api\ContentInterface; use Magento\Framework\Filesystem\Io\File; - class Content implements ContentInterface { const JSON_FILENAME = 'cms.json'; @@ -318,8 +317,7 @@ public function asZipFile(array $pageInterfaces, array $blockInterfaces) $zipArchive->addFromString(self::JSON_FILENAME, $jsonPayload); // Add media files - foreach ($contentArray['media'] as $mediaFile) - { + foreach ($contentArray['media'] as $mediaFile) { $absMediaPath = $this->filesystem->getMediaPath($mediaFile); if ($this->file->fileExists($absMediaPath, true)) { $zipArchive->addFile($absMediaPath, self::MEDIA_ARCHIVE_PATH . '/' . $mediaFile); @@ -481,9 +479,7 @@ public function importFromArray(array $payload, $archivePath = null) $destFile = $this->filesystem->getMediaPath($mediaFile); if ($this->file->fileExists($sourceFile, true)) { - - if ( - $this->file->fileExists($destFile, true) && + if ($this->file->fileExists($destFile, true) && ($this->mediaMode == ContentInterface::MEDIA_MODE_SKIP) ) { continue; diff --git a/Model/Filesystem.php b/Model/Filesystem.php index 3720bfd..3837773 100644 --- a/Model/Filesystem.php +++ b/Model/Filesystem.php @@ -24,7 +24,8 @@ use Magento\Framework\Filesystem\Io\File; use Magento\Framework\App\Filesystem\DirectoryList; -class Filesystem { +class Filesystem +{ const EXPORT_PATH = 'msp_cmsimportexport/export'; const EXTRACT_PATH = 'msp_cmsimportexport/extract'; const UPLOAD_PATH = 'msp_cmsimportexport/extract';