Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ces 984 customergroup product fixes #132

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions Component/CustomerGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public function execute($data = null)
if ($taxClassId) {
foreach ($taxClass['groups'] as $group) {
try {
if (isset($group['name'])) {
$this->createCustomerGroup($group['name'], $taxClassId);
}
$this->validateGroupName($group);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

essentially, this change is so that when the group is not created, we can work out why without having to get into the code

$this->createCustomerGroup($group['name'], $taxClassId);
} catch (ComponentException $e) {
$this->log->logError($e->getMessage());
}
Expand Down Expand Up @@ -100,6 +99,26 @@ private function createCustomerGroup($groupName, $taxClassId)
);
}

/**
* perform customer group name validation
*
* @param array $group
* @return null
* @throw ComponentException
*/
private function validateGroupName(array $group)
{
if (!isset($group['name'])) {
throw new ComponentException(__('The customer group name is mandatory'));
}

if (strlen($group['name'])>32) {
throw new ComponentException(
__('The customer group name "%1" is too long (maximum length is 32 characters)', $group['name'])
);
}
}

/**
* Return tax class id when given name
*
Expand Down
45 changes: 23 additions & 22 deletions Component/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
use Magento\Framework\Filesystem;
use Magento\Framework\App\Filesystem\DirectoryList;
use FireGento\FastSimpleImport\Model\Config;
use Magento\Framework\HTTP\ZendClient;
use Magento\Framework\HTTP\ZendClientFactory;
use GuzzleHttp\Client;
use GuzzleHttp\ClientFactory;
use GuzzleHttp\Exception\GuzzleException;

class Image
{
Expand All @@ -15,11 +16,6 @@ class Image
*/
protected $log;

/**
* @var ZendClientFactory
*/
protected $httpClientFactory;

/**
* @var Filesystem
*/
Expand All @@ -36,21 +32,25 @@ class Image
private $separator = ';';

/**
* Image constructor.
* @var ClientFactory
*/
private ClientFactory $clientFactory;

/**
* @param Filesystem $filesystem
* @param Config $importerConfig
* @param ZendClientFactory $httpClientFactory
* @param ClientFactory $clientFactory
* @param LoggerInterface $log
*/
public function __construct(
Filesystem $filesystem,
Config $importerConfig,
ZendClientFactory $httpClientFactory,
ClientFactory $clientFactory,
LoggerInterface $log
) {
$this->filesystem = $filesystem;
$this->importerConfig = $importerConfig;
$this->httpClientFactory = $httpClientFactory;
$this->clientFactory = $clientFactory;
$this->log = $log;
}

Expand Down Expand Up @@ -90,19 +90,19 @@ public function isValueURL($url)
public function downloadFile($value)
{
/**
* @var ZendClient $client
* @var Client $client
*/
$client = $this->httpClientFactory->create();
$client = $this->clientFactory->create(['config' => [
'base_uri' => $value
]]);
$response = '';

try {
$response = $client
benjamenjohnsondev marked this conversation as resolved.
Show resolved Hide resolved
->setUri($value)
->request('GET')
->getBody();
} catch (\Exception $e) {
$response = $client->request('GET')->getBody();
} catch (GuzzleException $e) {
$this->log->logError($e->getMessage());
}

return $response;
}

Expand Down Expand Up @@ -207,11 +207,12 @@ public function getImage($value)
*/
public function getFileDirectory(\Magento\Framework\Filesystem\Directory\WriteInterface $file)
{
$configurationValue = $this->importerConfig->getImportFileDir();
if (!empty($configurationValue)) {
return $file->getRelativePath($configurationValue);
try {
$configurationValue = $this->importerConfig->getImportFileDir();
return $file->getRelativePath($configurationValue);
} catch (\TypeError $e) {
return $file->getRelativePath('import');
}
return $file->getRelativePath('import');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Component/Product/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getImportRowFailures(Importer $import, $importLines)
{
$failedRows = [];
// Creates a validation model and runs the import data through so we can find which rows would fail
$validation = $import->createImportModel();
$validation = $import->getImportModel();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change implies we won't be backward compatible @paulpartington. Was not sure where the change came from to be honest.

$validationSource = $this->importAdapterFactory->create([
'data' => $importLines,
'multipleValueSeparator' => Products::SEPARATOR
Expand Down
1 change: 1 addition & 0 deletions Model/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ private function runAllComponents()

// Loop through components and run them individually in the master.yaml order
foreach ($master as $componentAlias => $componentConfig) {
if ($componentConfig['enabled'] === 0) continue;
// Run the component in question
$this->state->emulateAreaCode(
Area::AREA_ADMINHTML,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"phpunit/phpunit": "^6.2",
"magento/magento-coding-standard": "5"
},
"version": "3.2.0",
"version": "3.2.1",
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
Expand Down