Skip to content

Commit cf686db

Browse files
committed
#2 added proper handling of collections with eav entities
1 parent fc9774b commit cf686db

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/app/code/community/Hackathon/GridControl/Model/Observer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ public function eavCollectionAbstractLoadBefore(Varien_Event_Observer $event)
4343
*/
4444
$config = Mage::getSingleton('hackathon_gridcontrol/config');
4545

46-
// add attributes to collection
47-
//foreach ($config->getCollectionUpdates(Hackathon_GridControl_Model_Config::TYPE_ADD_ATTRIBUTE, $blockId) as $entry) {
48-
//$event->getCollection()->addAttributeToSelect($entry);
49-
//}
46+
// add attributes to eav collection
47+
if ($event->getCollection() instanceof Mage_Eav_Model_Entity_Collection_Abstract){
48+
foreach ($config->getCollectionUpdates(Hackathon_GridControl_Model_Config::TYPE_ADD_ATTRIBUTE, $blockId) as $entry) {
49+
$event->getCollection()->addAttributeToSelect($entry);
50+
}
51+
}
5052

5153
// join attributes to collection
5254
foreach ($config->getCollectionUpdates(Hackathon_GridControl_Model_Config::TYPE_JOIN_ATTRIBUTE, $blockId) as $attribute) {

src/app/code/community/Hackathon/GridControl/etc/config.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
</hackathon_gridcontrol>
3636
</observers>
3737
</core_collection_abstract_load_before>
38+
<eav_collection_abstract_load_before>
39+
<observers>
40+
<hackathon_gridcontrol>
41+
<type>singleton</type>
42+
<class>hackathon_gridcontrol/observer</class>
43+
<method>eavCollectionAbstractLoadBefore</method>
44+
</hackathon_gridcontrol>
45+
</observers>
46+
</eav_collection_abstract_load_before>
3847
</events>
3948
</adminhtml>
4049
</config>

0 commit comments

Comments
 (0)