Skip to content

Commit

Permalink
Added website strategy to import command & webapi
Browse files Browse the repository at this point in the history
  • Loading branch information
fazed committed Dec 20, 2021
1 parent 178aa27 commit cb5a782
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Api/ProductImportWebApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ProductImportWebApi implements ProductImportWebApiInterface
const OPTION_AUTO_CREATE_CATEGORIES = 'auto-create-categories';
const OPTION_CATEGORY_URL_TYPE = "category-url-type";
const OPTION_CATEGORY_STRATEGY = "category-strategy";
const OPTION_WEBSITE_STRATEGY = "website-strategy";
const OPTION_PATH_SEPARATOR = 'path-separator';
const OPTION_IMAGE_STRATEGY = 'image';
const OPTION_IMAGE_SOURCE_DIR = 'image-source-dir';
Expand Down Expand Up @@ -100,6 +101,10 @@ protected function buildConfig(array $parameters)
$config->categoryStrategy = $parameters[self::OPTION_CATEGORY_STRATEGY];
}

if (isset($parameters[self::OPTION_WEBSITE_STRATEGY])) {
$config->websiteStrategy = $parameters[self::OPTION_WEBSITE_STRATEGY];
}

if (isset($parameters[self::OPTION_EMPTY_TEXT])) {
$config->emptyTextValueStrategy = $parameters[self::OPTION_EMPTY_TEXT];
}
Expand Down Expand Up @@ -150,4 +155,4 @@ protected function buildConfig(array $parameters)

return $config;
}
}
}
11 changes: 10 additions & 1 deletion Console/Command/ProductImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ProductImportCommand extends Command
const OPTION_IMAGE_CACHING = "image-caching";
const OPTION_AUTO_CREATE_CATEGORIES = 'auto-create-categories';
const OPTION_CATEGORY_STRATEGY = "category-strategy";
const OPTION_WEBSITE_STRATEGY = "website-strategy";
const OPTION_PATH_SEPARATOR = 'path-separator';
const OPTION_CATEGORY_URL_TYPE = 'category-url-type';
const OPTION_IMAGE_STRATEGY = "image";
Expand Down Expand Up @@ -102,6 +103,13 @@ protected function configure()
'category strategy: How to handle product-category links that are not in the import (set: delete these links)',
ImportConfig::CATEGORY_STRATEGY_ADD
),
new InputOption(
self::OPTION_WEBSITE_STRATEGY,
null,
InputOption::VALUE_OPTIONAL,
'website strategy: How to handle product-website links that are not in the import (set: delete these links)',
ImportConfig::WEBSITE_STRATEGY_ADD
),
new InputOption(
self::OPTION_EMPTY_TEXT,
null,
Expand Down Expand Up @@ -216,6 +224,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$config->categoryNamePathSeparator = $input->getOption(self::OPTION_PATH_SEPARATOR);
$config->categoryUrlType = $input->getOption(self::OPTION_CATEGORY_URL_TYPE);
$config->categoryStrategy = $input->getOption(self::OPTION_CATEGORY_STRATEGY);
$config->websiteStrategy = $input->getOption(self::OPTION_WEBSITE_STRATEGY);
$config->productTypeChange = $input->getOption(self::OPTION_PRODUCT_TYPE_CHANGE);
$config->imageStrategy = $input->getOption(self::OPTION_IMAGE_STRATEGY);
$config->existingImageStrategy = $input->getOption(self::OPTION_IMAGE_CACHING);
Expand Down Expand Up @@ -273,4 +282,4 @@ protected function guessImageSourceDir(string $fileName, string $imageSourceDirO

return $dirName;
}
}
}

0 comments on commit cb5a782

Please sign in to comment.