ImportingParameters.php in Commerce Smart Importer 8
File
src/ImportingParameters.php
View source
<?php
namespace Drupal\commerce_smart_importer;
class ImportingParameters {
public $duplicateValues = TRUE;
public $incorrectValues = TRUE;
public $exceedsCardinality = TRUE;
public $defaultValues = TRUE;
public $appendImages = TRUE;
public $notValidVariations = TRUE;
public $createProduct = TRUE;
public $sku = TRUE;
public function disableAll() {
$this->duplicateValues = FALSE;
$this->incorrectValues = FALSE;
$this->exceedsCardinality = FALSE;
$this->defaultValues = FALSE;
$this->notValidVariations = FALSE;
$this->createProduct = FALSE;
$this->sku = FALSE;
}
public function matchParameters($field_logs) {
if ($this->createProduct === FALSE) {
return FALSE;
}
foreach ($field_logs as $field_log) {
if ($field_log['required'] === FALSE) {
return FALSE;
}
if ($this->defaultValues === FALSE && $field_log['default_value'] === FALSE) {
return FALSE;
}
if ($this->exceedsCardinality === FALSE && $field_log['cardinality'] === FALSE) {
return FALSE;
}
if ($this->duplicateValues === FALSE && $field_log['duplicates'] === FALSE) {
return FALSE;
}
if ($this->incorrectValues === FALSE && count($field_log['not_valid'])) {
return FALSE;
}
if (is_array($field_log) && array_key_exists('sku', $field_log)) {
if ($this->sku === FALSE && count($field_log['not_valid'])) {
return FALSE;
}
}
}
return TRUE;
}
public function matchOneFieldLog($field_log) {
if ($field_log['required'] === FALSE) {
return FALSE;
}
if ($this->defaultValues === FALSE && $field_log['default_value'] === FALSE) {
return FALSE;
}
if ($this->exceedsCardinality === FALSE && $field_log['cardinality'] === FALSE) {
return FALSE;
}
if ($this->duplicateValues === FALSE && $field_log['duplicates'] === FALSE) {
return FALSE;
}
if ($this->incorrectValues === FALSE && count($field_log['not_valid'])) {
return FALSE;
}
return TRUE;
}
}