Skip to content

Commit

Permalink
* PAC-96: Use new constands for FileUploadConfiguration
Browse files Browse the repository at this point in the history
    * techdivision/import#181
* PAC-361: Don't check file system if copy-images defined as false
    * techdivision/import-cli-simple#262
  • Loading branch information
Mardl committed Mar 26, 2021
1 parent a0e5fe6 commit 7d663ff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* Add functionality to clear URL rewrites when categories have been deleted
* Add #PAC-326: Cross-entity import of URLs (rewrites + redirects)
* Add #PAC-57: Deleting dedicated attribute values via import by setting a configurable value
* PAC-96: Use new constands for FileUploadConfiguration
* https://github.com/techdivision/import/issues/181
* PAC-361: Don't check file system if copy-images defined as false
* https://github.com/techdivision/import-cli-simple/issues/262

# Version 20.0.4

Expand Down
10 changes: 9 additions & 1 deletion src/Observers/CategoryObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,15 @@ protected function process()
$category = $this->initializeCategory($leaf ? $this->prepareDynamicAttributes() : array());

// persist and update the category with the new/existing entity ID
$category[$this->getPkMemberName()] = $this->persistCategory($category);
try {
$category[$this->getPkMemberName()] = $this->persistCategory($category);
} catch (\Exception $e) {
// if something went wrong in persist
// show more information to localize error in CSV
$message = $this->getSubject()->appendExceptionSuffix($e->getMessage());
$this->getSubject()->getSystemLogger()->critical($message, ['categoryPath' => $this->categoryPath]);
throw $e;
}

// append the ID of the new category to array with the IDs
array_push($this->categoryIds, $category[MemberNames::ENTITY_ID]);
Expand Down
27 changes: 17 additions & 10 deletions src/Subjects/BunchSubject.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use TechDivision\Import\Category\Utils\ConfigurationKeys;
use TechDivision\Import\Category\Utils\MemberNames;
use TechDivision\Import\Category\Utils\RegistryKeys;
use TechDivision\Import\Utils\FileUploadConfigurationKeys;

/**
* The subject implementation that handles the business logic to persist products.
Expand Down Expand Up @@ -115,30 +116,36 @@ public function setUp($serial)
$this->entityTypes = $status[RegistryKeys::GLOBAL_DATA][RegistryKeys::ENTITY_TYPES];

// initialize the flag whether to copy images or not
if ($this->getConfiguration()->hasParam(ConfigurationKeys::COPY_IMAGES)) {
$this->setCopyImages($this->getConfiguration()->getParam(ConfigurationKeys::COPY_IMAGES));
if ($this->getConfiguration()->hasParam(FileUploadConfigurationKeys::COPY_IMAGES)) {
$this->setCopyImages($this->getConfiguration()->getParam(FileUploadConfigurationKeys::COPY_IMAGES));
}

// initialize the flag whether to override images or not
if ($this->getConfiguration()->hasParam(ConfigurationKeys::OVERRIDE_IMAGES)) {
$this->setOverrideImages($this->getConfiguration()->getParam(ConfigurationKeys::OVERRIDE_IMAGES));
if ($this->getConfiguration()->hasParam(FileUploadConfigurationKeys::OVERRIDE_IMAGES)) {
$this->setOverrideImages($this->getConfiguration()->getParam(FileUploadConfigurationKeys::OVERRIDE_IMAGES));
}

// initialize media directory => can be absolute or relative
if ($this->getConfiguration()->hasParam(ConfigurationKeys::MEDIA_DIRECTORY)) {
if ($this->getConfiguration()->hasParam(FileUploadConfigurationKeys::MEDIA_DIRECTORY)) {
try {
$this->setMediaDir($this->resolvePath($this->getConfiguration()->getParam(ConfigurationKeys::MEDIA_DIRECTORY)));
$this->setMediaDir($this->resolvePath($this->getConfiguration()->getParam(FileUploadConfigurationKeys::MEDIA_DIRECTORY)));
} catch (\InvalidArgumentException $iae) {
$this->getSystemLogger()->debug($iae->getMessage());
// only if we wanna copy images we need directories
if ($this->hasCopyImages()) {
$this->getSystemLogger()->debug($iae->getMessage());
}
}
}

// initialize images directory => can be absolute or relative
if ($this->getConfiguration()->hasParam(ConfigurationKeys::IMAGES_FILE_DIRECTORY)) {
if ($this->getConfiguration()->hasParam(FileUploadConfigurationKeys::IMAGES_FILE_DIRECTORY)) {
try {
$this->setImagesFileDir($this->resolvePath($this->getConfiguration()->getParam(ConfigurationKeys::IMAGES_FILE_DIRECTORY)));
$this->setImagesFileDir($this->resolvePath($this->getConfiguration()->getParam(FileUploadConfigurationKeys::IMAGES_FILE_DIRECTORY)));
} catch (\InvalidArgumentException $iae) {
$this->getSystemLogger()->debug($iae->getMessage());
// only if we wanna copy images we need directories
if ($this->hasCopyImages()) {
$this->getSystemLogger()->debug($iae->getMessage());
}
}
}

Expand Down

0 comments on commit 7d663ff

Please sign in to comment.