Skip to content

Commit

Permalink
import-export-improvements #82 : configurable variations - not a supe…
Browse files Browse the repository at this point in the history
…r attribute error message improvements - travis ci build code style fix
  • Loading branch information
Tadhg Bowe committed Jun 29, 2018
1 parent 65bce0a commit 7f9f6db
Showing 1 changed file with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ

const ERROR_UNIDENTIFIABLE_VARIATION = 'unidentifiableVariation';

// @codingStandardsIgnoreStart
/**
* Validation failure message template definitions
*
* @var array
*
* Note: Many of these messages exceed maximum limit of 120 characters. Ignore from coding standards.
*/
protected $_messageTemplates = [
self::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST => 'Column configurable_variations: Attribute with code "%s" does not exist or is missing from product attribute set',
Expand All @@ -56,6 +59,7 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ
self::ERROR_DUPLICATED_VARIATIONS => 'SKU %s contains duplicated variations',
self::ERROR_UNIDENTIFIABLE_VARIATION => 'Configurable variation "%s" is unidentifiable',
];
// @codingStandardsIgnoreEnd

/**
* Column names that holds values with particular meaning.
Expand Down Expand Up @@ -300,8 +304,7 @@ protected function _isParticularAttributesValid(array $rowData, $rowNum)
$superAttrCode = $rowData['_super_attribute_code'];
if (!$this->_isAttributeSuper($superAttrCode)) {
// Identify reason why attribute is not super:
if (!$this->_identifySuperAttributeError($superAttrCode, $rowNum))
{
if (!$this->_identifySuperAttributeError($superAttrCode, $rowNum)) {
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_IS_NOT_SUPER, $rowNum, $superAttrCode);
}
return false;
Expand Down Expand Up @@ -334,36 +337,29 @@ protected function _identifySuperAttributeError($superAttrCode, $rowNum)
// Does this attribute code exist? Does is have the correct settings?
$commonAttributes = self::$commonAttributesCache;
foreach ($commonAttributes as $attributeRow) {

if ($attributeRow['code'] == $superAttrCode)
{
if ($attributeRow['code'] == $superAttrCode) {
$codeExists = true;

if ($attributeRow['is_global'] !== '1')
{
if ($attributeRow['is_global'] !== '1') {
$codeNotGlobal = true;
}
elseif ($attributeRow['type'] !== 'select')
{
elseif ($attributeRow['type'] !== 'select') {
$codeNotTypeSelect = true;
}

break;
}
}

if ($codeExists == false)
{
if ($codeExists == false) {
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_DOES_NOT_EXIST, $rowNum, $superAttrCode);
$reasonFound = true;
}
elseif ($codeNotGlobal == true)
{
elseif ($codeNotGlobal == true) {
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_GLOBAL_SCOPE, $rowNum, $superAttrCode);
$reasonFound = true;
}
elseif ($codeNotTypeSelect == true)
{
elseif ($codeNotTypeSelect == true) {
$this->_entityModel->addRowError(self::ERROR_ATTRIBUTE_CODE_NOT_TYPE_SELECT, $rowNum, $superAttrCode);
$reasonFound = true;
}
Expand Down

0 comments on commit 7f9f6db

Please sign in to comment.