Skip to content

Commit

Permalink
fix(TEN-661): use strtolower when searching existing skus
Browse files Browse the repository at this point in the history
_oldSkus is filled with lowercase skus, so we have to use strtolower.
See \Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::_getSkus
  • Loading branch information
Maikel-Koek committed Aug 29, 2023
1 parent efb7981 commit 5de15c3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Rewrite/ImportExport/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ protected function _saveProducts()

$rowData = $productTypeModel->prepareAttributesWithDefaultValueForSave(
$rowData,
!isset($this->_oldSku[$rowSku])
!isset($this->_oldSku[strtolower($rowSku)])
);
$product = $this->_proxyProdFactory->create(['data' => $rowData]);

Expand Down Expand Up @@ -551,7 +551,7 @@ protected function _saveProducts()
} elseif (self::SCOPE_STORE == $attribute->getIsGlobal()) {
$storeIds = [$rowStore];
}
if (!isset($this->_oldSku[$rowSku])) {
if (!isset($this->_oldSku[strtolower($rowSku)])) {
$storeIds[] = 0;
}
}
Expand Down Expand Up @@ -597,7 +597,7 @@ protected function _saveProducts()

public function skipUpdatingAttribute($rowSku, $attrCode)
{
return isset($this->_oldSku[$rowSku]) && \array_key_exists(self::SKIP_ATTRIBUTES_WHEN_UPDATING, $this->_parameters) && \array_key_exists($attrCode, $this->_parameters[self::SKIP_ATTRIBUTES_WHEN_UPDATING]);
return isset($this->_oldSku[strtolower($rowSku)]) && \array_key_exists(self::SKIP_ATTRIBUTES_WHEN_UPDATING, $this->_parameters) && \array_key_exists($attrCode, $this->_parameters[self::SKIP_ATTRIBUTES_WHEN_UPDATING]);
}

/**
Expand Down Expand Up @@ -637,7 +637,7 @@ public function validateRow(array $rowData, $rowNum)
$rowScope = $this->getRowScope($rowData);
// BEHAVIOR_DELETE use specific validation logic
if (Import::BEHAVIOR_DELETE == $this->getBehavior()) {
if (self::SCOPE_DEFAULT == $rowScope && !isset($this->_oldSku[$rowData[self::COL_SKU]])) {
if (self::SCOPE_DEFAULT == $rowScope && !isset($this->_oldSku[strtolower($rowData[self::COL_SKU])])) {
$this->addRowError(ValidatorInterface::ERROR_SKU_NOT_FOUND_FOR_DELETE, $rowNum);
return false;
}
Expand Down

0 comments on commit 5de15c3

Please sign in to comment.