Skip to content

Commit 6d719fd

Browse files
committed
ACP2E-1522: Auto increment number jumping up for catalog_product_entity_* tables
- Fixed the build error.
1 parent fbdd4a1 commit 6d719fd

File tree

2 files changed

+14
-40
lines changed

2 files changed

+14
-40
lines changed

app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,19 @@ protected function _insertAttribute($object, $attribute, $value)
325325
*/
326326
protected function _updateAttribute($object, $attribute, $valueId, $value)
327327
{
328-
return $this->_saveAttributeValue($object, $attribute, $value);
328+
if ($valueId > 0) {
329+
$table = $attribute->getBackend()->getTable();
330+
$connection = $this->getConnection();
331+
$connection->update(
332+
$table,
333+
['value' => $this->_prepareValueForSave($value, $attribute)],
334+
sprintf('%s=%d', $connection->quoteIdentifier('value_id'), $valueId)
335+
);
336+
337+
return $this;
338+
} else {
339+
return $this->_saveAttributeValue($object, $attribute, $value);
340+
}
329341
}
330342

331343
/**

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,6 @@ protected function _deleteAttributes($object, $table, $info)
16691669
*/
16701670
public function saveAttribute(DataObject $object, $attributeCode)
16711671
{
1672-
$updateValue = 0;
16731672
$attribute = $this->getAttribute($attributeCode);
16741673
$backend = $attribute->getBackend();
16751674
$table = $backend->getTable();
@@ -1700,15 +1699,10 @@ public function saveAttribute(DataObject $object, $attributeCode)
17001699
$this->_insertAttribute($object, $attribute, $newValue);
17011700
} elseif ($origValueId !== false && $newValue !== null) {
17021701
$this->_updateAttribute($object, $attribute, $origValueId, $newValue);
1703-
$updateValue = 1;
17041702
} elseif ($origValueId !== false && $newValue === null && $origValue !== null) {
17051703
$connection->delete($table, $where);
17061704
}
1707-
if ($updateValue === 1 && $origValue === $newValue) {
1708-
$this->_updateAttributeValues($attribute, $origValueId);
1709-
} else {
1710-
$this->_processAttributeValues();
1711-
}
1705+
$this->_processAttributeValues();
17121706
$connection->commit();
17131707
} catch (\Exception $e) {
17141708
$connection->rollBack();
@@ -2017,36 +2011,4 @@ protected function loadAttributesForObject($attributes, $object = null)
20172011
}
20182012
}
20192013
}
2020-
2021-
/**
2022-
* Update entity attribute values
2023-
*
2024-
* @param AbstractAttribute $attribute
2025-
* @param mixed $valueId
2026-
* @return $this
2027-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2028-
*/
2029-
private function _updateAttributeValues(AbstractAttribute $attribute, mixed $valueId): static
2030-
{
2031-
$connection = $this->getConnection();
2032-
foreach ($this->_attributeValuesToSave as $table => $data) {
2033-
foreach ($data as $columnValue) {
2034-
$connection->update(
2035-
$table,
2036-
['value' => $this->_prepareValueForSave($columnValue['value'], $attribute)],
2037-
sprintf('%s=%d', $connection->quoteIdentifier('value_id'), $valueId)
2038-
);
2039-
}
2040-
}
2041-
2042-
foreach ($this->_attributeValuesToDelete as $table => $valueIds) {
2043-
$connection->delete($table, ['value_id IN (?)' => $valueIds]);
2044-
}
2045-
2046-
// reset data arrays
2047-
$this->_attributeValuesToSave = [];
2048-
$this->_attributeValuesToDelete = [];
2049-
2050-
return $this;
2051-
}
20522014
}

0 commit comments

Comments
 (0)