Skip to content

Commit

Permalink
Add further checks for attribute keys.
Browse files Browse the repository at this point in the history
Check if the array key exists rather than using isset to allow for blank values.
  • Loading branch information
paulpartington-cti committed May 3, 2017
1 parent d80ffa6 commit db523cc
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions Model/Component/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ protected function checkForAttributeUpdates($attributeCode, $attributeArray, $at
$requiresUpdate = false;
$nest = 1;
foreach ($attributeConfig as $name => $value) {

if ($name == "product_types") {
$value = implode(',', $value);
}
Expand All @@ -118,8 +117,7 @@ protected function checkForAttributeUpdates($attributeCode, $attributeArray, $at
if ($name == 'option') {
continue;
}

if (!isset($attributeArray[$name])) {
if (!array_key_exists($name, $attributeArray)) {
$this->log->logError(sprintf(
'Attribute %s type %s does not exist or is not mapped',
$attributeCode,
Expand Down Expand Up @@ -155,20 +153,28 @@ protected function checkForAttributeUpdates($attributeCode, $attributeArray, $at

protected function mapAttributeConfig($name)
{
if ($name == 'label') {
$name = 'frontend_label';
}

if ($name == 'type') {
$name = 'backend_type';
}

if ($name == 'input') {
$name = 'frontend_input';
}

if ($name == 'product_types') {
$name = 'apply_to';
switch ($name) {
case 'label':
$name = 'frontend_label';
break;
case 'type':
$name = 'backend_type';
break;
case 'input':
$name = 'frontend_input';
break;
case 'product_types':
$name = 'apply_to';
break;
case 'required':
$name = 'is_required';
break;
case 'source':
$name = 'source_model';
break;
case 'backend':
$name = 'backend_model';
break;
}
return $name;
}
Expand Down

0 comments on commit db523cc

Please sign in to comment.