Skip to content

Commit 9ff5c56

Browse files
Fix website-specific attribute values not loading correctly (#4745)
* Fix: Use XML-configured attribute collection or eav/entity_attribute_collection as default * fix issues with eav cache * if collection supports per-website values, set website id * php-cs-fix * Use instanceof check instead of method_exists for website-specific attribute value --------- Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent 7e2130e commit 9ff5c56

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

app/code/core/Mage/Eav/Model/Config.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,16 @@ protected function _loadEntityAttributes($entityType, $storeId)
224224
{
225225
// preload attributes in array form to avoid instantiating
226226
// models for every attribute even if it is never accessed
227-
$entityAttributes = $entityType->newAttributeCollection()
228-
->addStoreLabel($storeId)
229-
->getData();
227+
$collection = $entityType->newAttributeCollection()
228+
->addStoreLabel($storeId);
229+
230+
// if collection supports per-website values, set website id
231+
if ($collection instanceof Mage_Eav_Model_Resource_Attribute_Collection) {
232+
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
233+
$collection->setWebsite($websiteId);
234+
}
235+
236+
$entityAttributes = $collection->getData();
230237

231238
$this->_entityTypeAttributes[$storeId][$entityType->getId()] = [];
232239
$attributeCodes = [];

app/code/core/Mage/Eav/Model/Entity/Type.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ public function newAttributeCollection($setId = null)
140140
*/
141141
protected function _getAttributeCollection()
142142
{
143-
$collection = Mage::getModel('eav/entity_attribute')->getCollection();
143+
$collectionClass = $this->getEntityAttributeCollection();
144+
$collection = Mage::getResourceModel($collectionClass);
144145
$objectsModel = $this->getAttributeModel();
145146
if ($objectsModel) {
146147
$collection->setModel($objectsModel);

0 commit comments

Comments
 (0)