Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2025 Adobe
* All Rights Reserved.
*/

namespace Magento\Eav\Model\Entity\Collection;
Expand Down Expand Up @@ -1233,8 +1233,27 @@ public function _loadAttributes($printQuery = false, $logQuery = false)
throw $e;
}

$attributeCode = $data = [];
$entityIdField = $entity->getEntityIdField();

foreach ($values as $value) {
$this->_setItemAttributeValue($value);
$entityId = $value[$entityIdField];
$attributeId = $value['attribute_id'];
if (!isset($attributeCode[$attributeId])) {
$attributeCode[$attributeId] = array_search($attributeId, $this->_selectAttributes);
if (!$attributeCode[$attributeId]) {
$attribute = $this->_eavConfig->getAttribute(
$this->getEntity()->getType(),
$attributeId
);
$attributeCode[$attributeId] = $attribute->getAttributeCode();
}
}
$data[$entityId][$attributeCode[$attributeId]] = $value['value'];
}

if ($data) {
$this->_setItemAttributeValue($data);
}
}
}
Expand Down Expand Up @@ -1303,32 +1322,22 @@ protected function _addLoadAttributesSelectValues($select, $table, $type)
/**
* Initialize entity object property value
*
* Parameter $valueInfo is _getLoadAttributesSelect fetch result row
* Parameter $valueInfo is [product_id => [attribute_code => value]]
*
* @param array $valueInfo
* @return $this
* @throws LocalizedException
*/
protected function _setItemAttributeValue($valueInfo)
{
$entityIdField = $this->getEntity()->getEntityIdField();
$entityId = $valueInfo[$entityIdField];
if (!isset($this->_itemsById[$entityId])) {
throw new LocalizedException(
__('A header row is missing for an attribute. Verify the header row and try again.')
);
}
$attributeCode = array_search($valueInfo['attribute_id'], $this->_selectAttributes);
if (!$attributeCode) {
$attribute = $this->_eavConfig->getAttribute(
$this->getEntity()->getType(),
$valueInfo['attribute_id']
);
$attributeCode = $attribute->getAttributeCode();
}

foreach ($this->_itemsById[$entityId] as $object) {
$object->setData($attributeCode, $valueInfo['value']);
foreach ($valueInfo as $entityId => $value) {
if (!isset($this->_itemsById[$entityId])) {
throw new LocalizedException(
__('A header row is missing for an attribute. Verify the header row and try again.')
);
}
$object =$this->_itemsById[$entityId][0];
$object->setData($object->getData()+$value);
}

return $this;
Expand Down