Skip to content

Commit

Permalink
Changes according to pull request reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
avstudnitz committed Sep 30, 2022
1 parent 57fbe6a commit c5f904e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Model/Adapters/NestedArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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: 1 addition & 3 deletions Model/Config/Source/Behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions Model/Config/Source/ValidationStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 14 additions & 8 deletions Model/Import/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class Category extends \Magento\ImportExport\Model\Import\AbstractEntity
private $symbolIgnoreFields = false;

private int $defaultAttributeSetId = 0;
private CategoryImportVersion $categoryImportVersionFeature;
private ?CategoryImportVersion $categoryImportVersionFeature;
private ?Uploader $fileUploader = null;
private DirectoryWriteInterface $mediaDirectory;
private StoreManagerInterface $storeManager;
Expand Down Expand Up @@ -383,7 +383,7 @@ private function initCategories(): self
}

$index = $this->implodeEscaped(
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
(string) $this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
$path
);
$this->categoriesWithRoots[$rootCategoryName][$index] = [
Expand Down Expand Up @@ -861,13 +861,13 @@ private function getCategoryName(array $rowData): string
}

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

private function explodeEscaped(string $delimiter = '/', string $string): array
private function explodeEscaped(string $delimiter, string $string): array
{
$exploded = explode($delimiter, $string);
$fixed = [];
Expand Down Expand Up @@ -911,12 +911,12 @@ protected function getParentCategory(array $rowData)
$parent = $categoryParts[count($categoryParts) - 2];
} else {
$categoryParts = $this->explodeEscaped(
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
(string) $this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
$rowData[self::COL_CATEGORY]
);
array_pop($categoryParts);
$parent = $this->implodeEscaped(
$this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
(string) $this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR),
$categoryParts
);
}
Expand Down Expand Up @@ -1170,7 +1170,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,7 +1199,11 @@ private function saveCategoryEntity(array $entityRowsIn, array $entityRowsUp): s
*/
private function saveCategoryAttributes(array $attributesData): self
{
$entityFieldName = $this->categoryImportVersionFeature->getEntityFieldName();
if ($this->categoryImportVersionFeature !== null) {
$entityFieldName = $this->categoryImportVersionFeature->getEntityFieldName();
} else {
$entityFieldName = 'entity_id';
}

$entityIds = array();

Expand Down

0 comments on commit c5f904e

Please sign in to comment.