From 70a96e83692400503f2fa39ece22b3e8cca3173c Mon Sep 17 00:00:00 2001 From: Raphael Petrini Date: Wed, 9 Mar 2016 14:58:52 +0100 Subject: [PATCH 1/3] fix issue #3704 regarding integer attribute values being cast to decimal --- .../Eav/Model/Entity/Collection/AbstractCollection.php | 6 +++++- app/code/Magento/Eav/Model/ResourceModel/Helper.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index 0e151c5de831f..0780129130212 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -1175,7 +1175,11 @@ public function _loadAttributes($printQuery = false, $logQuery = false) foreach ($selectGroups as $selects) { if (!empty($selects)) { try { - $select = implode(' UNION ALL ', $selects); + if (is_array($selects)) + { + $select = implode(' UNION ALL ', $selects); + } + else $select = $selects; $values = $this->getConnection()->fetchAll($select); } catch (\Exception $e) { $this->printLogQuery(true, true, $select); diff --git a/app/code/Magento/Eav/Model/ResourceModel/Helper.php b/app/code/Magento/Eav/Model/ResourceModel/Helper.php index 994b131bfd78f..2521e76af3e4c 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Helper.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Helper.php @@ -80,6 +80,6 @@ public function getLoadAttributesSelectGroups($selects) foreach ($selects as $selectGroup) { $mainGroup = array_merge($mainGroup, $selectGroup); } - return [$mainGroup]; + return $mainGroup; } } From 516bbe8dbb6b792d2dc92296e5c6aee53269a007 Mon Sep 17 00:00:00 2001 From: Raphael Petrini Date: Wed, 9 Mar 2016 16:40:45 +0100 Subject: [PATCH 2/3] fix code style --- .../Eav/Model/Entity/Collection/AbstractCollection.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index 0780129130212..8114b0db256fd 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -1175,11 +1175,11 @@ public function _loadAttributes($printQuery = false, $logQuery = false) foreach ($selectGroups as $selects) { if (!empty($selects)) { try { - if (is_array($selects)) - { + if (is_array($selects)) { $select = implode(' UNION ALL ', $selects); + } else { + $select = $selects; } - else $select = $selects; $values = $this->getConnection()->fetchAll($select); } catch (\Exception $e) { $this->printLogQuery(true, true, $select); From 3f9b64b5bed667c0a03070270bbcdc62898b65ba Mon Sep 17 00:00:00 2001 From: Raphael Petrini Date: Thu, 10 Mar 2016 09:37:12 +0100 Subject: [PATCH 3/3] apply fix to the AbstractEntity --- app/code/Magento/Eav/Model/Entity/AbstractEntity.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index f9bc1bb9617d7..d6aaab6c34d56 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -1064,7 +1064,11 @@ protected function _loadModelAttributes($object) $selectGroups = $this->_resourceHelper->getLoadAttributesSelectGroups($selects); foreach ($selectGroups as $selects) { if (!empty($selects)) { - $select = $this->_prepareLoadSelect($selects); + if (is_array($selects)) { + $select = $this->_prepareLoadSelect($selects); + } else { + $select = $selects; + } $values = $this->getConnection()->fetchAll($select); foreach ($values as $valueRow) { $this->_setAttributeValue($object, $valueRow);