Skip to content

Commit e99c99e

Browse files
author
Tadhg Bowe
committed
import-export-improvements #82 : configurable variations - not a super attribute error message improvements
1 parent 70c5c51 commit e99c99e

File tree

1 file changed

+53
-3
lines changed
  • app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type

1 file changed

+53
-3
lines changed

app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ
2525
/**
2626
* Error codes.
2727
*/
28+
const ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST = 'attrCodeDoesNotExist';
29+
30+
const ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE = 'attrCodeNotGlobalScope';
31+
32+
const ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT = 'attrCodeNotTypeSelect';
33+
2834
const ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER = 'attrCodeIsNotSuper';
2935

3036
const ERROR_INVALID_OPTION_VALUE = 'invalidOptionValue';
@@ -41,8 +47,11 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ
4147
* @var array
4248
*/
4349
protected $_messageTemplates = [
44-
self::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER => 'Attribute with code "%s" is not super',
45-
self::ERROR_INVALID_OPTION_VALUE => 'Invalid option value for attribute "%s"',
50+
self::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST => 'Column configurable_variations: Attribute with code "%s" does not exist or is missing from product attribute set',
51+
self::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE => 'Column configurable_variations: Attribute with code "%s" is not super - it needs to have Global Scope',
52+
self::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT => 'Column configurable_variations: Attribute with code "%s" is not super - it needs to be Input Type of Dropdown, Visual Swatch or Text Swatch',
53+
self::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER => 'Column configurable_variations: Attribute with code "%s" is not super',
54+
self::ERROR_INVALID_OPTION_VALUE => 'Column configurable_variations: Invalid option value for attribute "%s"',
4655
self::ERROR_INVALID_WEBSITE => 'Invalid website code for super attribute',
4756
self::ERROR_DUPLICATED_VARIATIONS => 'SKU %s contains duplicated variations',
4857
self::ERROR_UNIDENTIFIABLE_VARIATION => 'Configurable variation "%s" is unidentifiable',
@@ -291,9 +300,50 @@ protected function _isParticularAttributesValid(array $rowData, $rowNum)
291300
$superAttrCode = $rowData['_super_attribute_code'];
292301

293302
if (!$this->_isAttributeSuper($superAttrCode)) {
294-
// check attribute superity
303+
// This attribute code is not a super attribute. Need to give a clearer message why?
304+
$codeExists = false;
305+
$codeNotGlobal = false;
306+
$codeNotTypeSelect = false;
307+
// Does this attribute code exist? Does is have the correct settings?
308+
$commonAttributes = self::$commonAttributesCache;
309+
foreach ($commonAttributes as $attributeRow) {
310+
311+
if ($attributeRow['code'] == $superAttrCode)
312+
{
313+
$codeExists = true;
314+
315+
if ($attributeRow['is_global'] !== '1')
316+
{
317+
$codeNotGlobal = true;
318+
}
319+
elseif ($attributeRow['type'] !== 'select')
320+
{
321+
$codeNotTypeSelect = true;
322+
}
323+
324+
break;
325+
}
326+
}
327+
328+
if ($codeExists == false)
329+
{
330+
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST, $rowNum, $superAttrCode);
331+
return false;
332+
}
333+
elseif ($codeNotGlobal == true)
334+
{
335+
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE, $rowNum, $superAttrCode);
336+
return false;
337+
}
338+
elseif ($codeNotTypeSelect == true)
339+
{
340+
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT, $rowNum, $superAttrCode);
341+
return false;
342+
}
343+
295344
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER, $rowNum, $superAttrCode);
296345
return false;
346+
297347
} elseif (isset($rowData['_super_attribute_option']) && strlen($rowData['_super_attribute_option'])) {
298348
$optionKey = strtolower($rowData['_super_attribute_option']);
299349
if (!isset($this->_superAttributes[$superAttrCode]['options'][$optionKey])) {

0 commit comments

Comments
 (0)