Skip to content

Commit

Permalink
Merge branch 'develop' into rb
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrown authored Oct 21, 2022
2 parents bc21051 + 6d32161 commit f16d7c5
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 79 deletions.
5 changes: 5 additions & 0 deletions Exception/ImportException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

declare(strict_types=1);

namespace FireGento\FastSimpleImport\Exception;
Expand Down
5 changes: 5 additions & 0 deletions Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

declare(strict_types=1);

namespace FireGento\FastSimpleImport\Exception;
Expand Down
5 changes: 5 additions & 0 deletions Exception/ValidationException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

declare(strict_types=1);

namespace FireGento\FastSimpleImport\Exception;
Expand Down
4 changes: 2 additions & 2 deletions Model/Adapters/ArrayAdapter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Adapters;
Expand Down
4 changes: 2 additions & 2 deletions Model/Adapters/ArrayAdapterFactory.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Adapters;
Expand Down
4 changes: 2 additions & 2 deletions Model/Adapters/ImportAdapterFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Adapters;
Expand Down
8 changes: 4 additions & 4 deletions Model/Adapters/NestedArrayAdapter.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Adapters;
Expand All @@ -26,9 +26,9 @@ public function __construct(array $data, string $multipleValueSeparator = ', ')
}

/**
* Transform nested array to string
* Transform nested array to flat array of strings
*/
private function convertToArray(array &$line)
private function convertToArray(array &$line): void
{
$implodeStr = $this->multipleValueSeparator;
$array = array_map(
Expand Down
4 changes: 2 additions & 2 deletions Model/Adapters/NestedArrayAdapterFactory.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Adapters;
Expand Down
13 changes: 9 additions & 4 deletions Model/Config.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model;

use Magento\Framework\App\Helper\AbstractHelper;
Expand All @@ -16,8 +17,7 @@ class Config extends AbstractHelper
private const XML_PATH_VALIDATION_STRATEGY = 'fastsimpleimport/default/validation_strategy';
private const XML_PATH_ALLOWED_ERROR_COUNT = 'fastsimpleimport/default/allowed_error_count';
private const XML_PATH_IMPORT_IMAGES_FILE_FIR = 'fastsimpleimport/default/import_images_file_dir';

public const XML_PATH_CATEGORY_PATH_SEPERATOR = 'fastsimpleimport/default/category_path_seperator';
private const XML_PATH_CATEGORY_PATH_SEPERATOR = 'fastsimpleimport/default/category_path_seperator';

public function __construct(
Context $context
Expand Down Expand Up @@ -54,4 +54,9 @@ public function getImportFileDir(): string
{
return $this->scopeConfig->getValue(self::XML_PATH_IMPORT_IMAGES_FILE_FIR);
}

public function getCategoryPathSeparator(): string
{
return $this->scopeConfig->getValue(self::XML_PATH_CATEGORY_PATH_SEPERATOR);
}
}
8 changes: 3 additions & 5 deletions Model/Config/Source/Behavior.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Config\Source;
Expand All @@ -14,10 +14,8 @@ class Behavior implements \Magento\Framework\Option\ArrayInterface

/**
* Return available behaviors
*
* @return array
*/
public function toOptionArray()
public function toOptionArray(): array
{
if ($this->options === null) {
$this->options = [
Expand Down
8 changes: 3 additions & 5 deletions Model/Config/Source/ValidationStrategy.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Config\Source;
Expand All @@ -14,10 +14,8 @@ class ValidationStrategy implements \Magento\Framework\Option\ArrayInterface

/**
* Return available validation strategies
*
* @return array
*/
public function toOptionArray()
public function toOptionArray(): array
{
if ($this->options === null) {
$this->options = [
Expand Down
5 changes: 5 additions & 0 deletions Model/Enterprise/CategoryImportVersion.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Enterprise;

use Magento\Staging\Model\VersionManager;
Expand Down
5 changes: 5 additions & 0 deletions Model/Enterprise/VersionFeaturesFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Enterprise;

use Magento\Framework\ObjectManagerInterface;
Expand Down
53 changes: 23 additions & 30 deletions Model/Import/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class Category extends \Magento\ImportExport\Model\Import\AbstractEntity
private CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator;
private UrlPersistInterface $urlPersist;
private CategoryRepositoryInterface $categoryRepository;
private Config $config;

public function __construct(
StringUtils $string,
Expand All @@ -239,6 +240,7 @@ public function __construct(
CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator,
CategoryRepositoryInterface $categoryRepository,
UrlPersistInterface $urlPersist,
Config $config,
array $data = []
) {
parent::__construct(
Expand Down Expand Up @@ -279,8 +281,9 @@ public function __construct(
->initAttributes()
->initAttributeSetId();

$this->entityTable = $this->defaultCategory->getResource()->getEntityTable();
$this->entityTable = $this->defaultCategory->getResource()->getEntityTable();
$this->categoryImportVersionFeature = $this->versionFeatures->create('CategoryImportVersion');
$this->config = $config;
}

/**
Expand Down Expand Up @@ -382,10 +385,7 @@ private function initCategories(): self
$this->categoriesWithRoots[$rootCategoryName] = [];
}

$index = $this->implodeEscaped(
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
$path
);
$index = $this->implodeEscaped($this->config->getCategoryPathSeparator(), $path);
$this->categoriesWithRoots[$rootCategoryName][$index] = [
'entity_id' => $category->getId(),
CategoryInterface::KEY_PATH => $category->getData(CategoryInterface::KEY_PATH),
Expand Down Expand Up @@ -417,10 +417,7 @@ private function implodeEscaped(?string $glue, array $array): string
foreach ($array as $value) {
$newArray[] = str_replace($glue, '\\' . $glue, $value);
}
return implode(
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
$newArray
);
return implode($this->config->getCategoryPathSeparator(), $newArray);
}

/**
Expand Down Expand Up @@ -616,10 +613,11 @@ private function indexDeleteEvents(): self
* @return $this
* @throws \Exception
*/
private function reindexUpdatedCategories($categoryId)
protected function reindexUpdatedCategories($categoryId)
{
/** @var $category CategoryModel */
$category = $this->defaultCategory->load($categoryId);
/** @var $category \Magento\Catalog\Model\Category */
$category = $this->categoryRepository->get($categoryId);

foreach ($category->getStoreIds() as $storeId) {
if ($storeId == 0) {
continue;
Expand Down Expand Up @@ -859,15 +857,11 @@ private function getCategoryName(array $rowData): string
if (isset($rowData[CategoryModel::KEY_NAME]) && strlen($rowData[CategoryModel::KEY_NAME])) {
return $rowData[CategoryModel::KEY_NAME];
}

$categoryParts = $this->explodeEscaped(
$rowData[self::COL_CATEGORY],
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR)
);
$categoryParts = $this->explodeEscaped($this->config->getCategoryPathSeparator(), $rowData[self::COL_CATEGORY]);
return end($categoryParts);
}

private function explodeEscaped(string $string, string $delimiter = '/'): array
private function explodeEscaped(string $delimiter, string $string): array
{
$exploded = explode($delimiter, $string);
$fixed = [];
Expand Down Expand Up @@ -910,15 +904,10 @@ protected function getParentCategory(array $rowData)
);
$parent = $categoryParts[count($categoryParts) - 2];
} else {
$categoryParts = $this->explodeEscaped(
$rowData[self::COL_CATEGORY],
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR)
);
$categoryParts = $this->explodeEscaped($this->config->getCategoryPathSeparator(),
$rowData[self::COL_CATEGORY]);
array_pop($categoryParts);
$parent = $this->implodeEscaped(
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
$categoryParts
);
$parent = $this->implodeEscaped($this->config->getCategoryPathSeparator(), $categoryParts);
}

if ($parent) {
Expand Down Expand Up @@ -1170,7 +1159,9 @@ private function getUploader(): Uploader
private function saveCategoryEntity(array $entityRowsIn, array $entityRowsUp): self
{
if ($entityRowsIn) {
$entityRowsIn = $this->categoryImportVersionFeature->processCategory($entityRowsIn);
if ($this->categoryImportVersionFeature !== null) {
$entityRowsIn = $this->categoryImportVersionFeature->processCategory($entityRowsIn);
}

$this->_connection->insertMultiple($this->entityTable, $entityRowsIn);
}
Expand All @@ -1197,9 +1188,11 @@ private function saveCategoryEntity(array $entityRowsIn, array $entityRowsUp): s
*/
private function saveCategoryAttributes(array $attributesData): self
{
$entityFieldName = $this->categoryImportVersionFeature ?
$this->categoryImportVersionFeature->getEntityFieldName() :
'entity_id';
if ($this->categoryImportVersionFeature !== null) {
$entityFieldName = $this->categoryImportVersionFeature->getEntityFieldName();
} else {
$entityFieldName = 'entity_id';
}

$entityIds = array();

Expand Down
5 changes: 3 additions & 2 deletions Model/Import/Proxy/Category/ResourceModel.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model\Import\Proxy\Category;

class ResourceModel extends \Magento\Catalog\Model\ResourceModel\Category
Expand Down
4 changes: 2 additions & 2 deletions Model/Importer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Model;
Expand Down
4 changes: 2 additions & 2 deletions ResourceModel/ImportData.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\ResourceModel;
Expand Down
4 changes: 2 additions & 2 deletions Service/ImportErrorService.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/

namespace FireGento\FastSimpleImport\Service;
Expand Down
4 changes: 2 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
Expand Down
4 changes: 2 additions & 2 deletions etc/config.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
Expand Down
4 changes: 2 additions & 2 deletions etc/di.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 FireGento e.V. - All rights reserved.
* See LICENSE.md bundled with this module for license details.
* @copyright © 2016 - 2022 FireGento e.V. - All rights reserved.
* @license https://opensource.org/licenses/GPL-3.0 GPL-3
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
Loading

0 comments on commit f16d7c5

Please sign in to comment.