Skip to content

Commit 65bce0a

Browse files
author
Tadhg Bowe
committed
import-export-improvements #82 : configurable variations - not a super attribute error message improvements - travis ci build code fix
1 parent e99c99e commit 65bce0a

File tree

1 file changed

+58
-42
lines changed
  • app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type

1 file changed

+58
-42
lines changed

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

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -298,52 +298,13 @@ protected function _isParticularAttributesValid(array $rowData, $rowNum)
298298
{
299299
if (!empty($rowData['_super_attribute_code'])) {
300300
$superAttrCode = $rowData['_super_attribute_code'];
301-
302301
if (!$this->_isAttributeSuper($superAttrCode)) {
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)
302+
// Identify reason why attribute is not super:
303+
if (!$this->_identifySuperAttributeError($superAttrCode, $rowNum))
334304
{
335-
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE, $rowNum, $superAttrCode);
336-
return false;
305+
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER, $rowNum, $superAttrCode);
337306
}
338-
elseif ($codeNotTypeSelect == true)
339-
{
340-
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT, $rowNum, $superAttrCode);
341-
return false;
342-
}
343-
344-
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER, $rowNum, $superAttrCode);
345307
return false;
346-
347308
} elseif (isset($rowData['_super_attribute_option']) && strlen($rowData['_super_attribute_option'])) {
348309
$optionKey = strtolower($rowData['_super_attribute_option']);
349310
if (!isset($this->_superAttributes[$superAttrCode]['options'][$optionKey])) {
@@ -355,6 +316,61 @@ protected function _isParticularAttributesValid(array $rowData, $rowNum)
355316
return true;
356317
}
357318

319+
/**
320+
* Identify exactly why a super attribute code is not super.
321+
*
322+
* @param string $superAttrCode
323+
* @param int $rowNum
324+
* @return bool
325+
*/
326+
protected function _identifySuperAttributeError($superAttrCode, $rowNum)
327+
{
328+
// This attribute code is not a super attribute. Need to give a clearer message why?
329+
$reasonFound = false;
330+
331+
$codeExists = false;
332+
$codeNotGlobal = false;
333+
$codeNotTypeSelect = false;
334+
// Does this attribute code exist? Does is have the correct settings?
335+
$commonAttributes = self::$commonAttributesCache;
336+
foreach ($commonAttributes as $attributeRow) {
337+
338+
if ($attributeRow['code'] == $superAttrCode)
339+
{
340+
$codeExists = true;
341+
342+
if ($attributeRow['is_global'] !== '1')
343+
{
344+
$codeNotGlobal = true;
345+
}
346+
elseif ($attributeRow['type'] !== 'select')
347+
{
348+
$codeNotTypeSelect = true;
349+
}
350+
351+
break;
352+
}
353+
}
354+
355+
if ($codeExists == false)
356+
{
357+
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST, $rowNum, $superAttrCode);
358+
$reasonFound = true;
359+
}
360+
elseif ($codeNotGlobal == true)
361+
{
362+
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE, $rowNum, $superAttrCode);
363+
$reasonFound = true;
364+
}
365+
elseif ($codeNotTypeSelect == true)
366+
{
367+
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT, $rowNum, $superAttrCode);
368+
$reasonFound = true;
369+
}
370+
371+
return $reasonFound;
372+
}
373+
358374
/**
359375
* Array of SKU to array of super attribute values for all products.
360376
*

0 commit comments

Comments
 (0)