Last active
August 29, 2015 14:18
-
-
Save molotovbliss/dcc8657590ae5a0b8ea0 to your computer and use it in GitHub Desktop.
Get attributes via Flat table instead of EAV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Get attributes via Flat table instead of EAV alternative to the resource heavy | |
* $product->getTypeInstance()->getConfigurableAttributesAsArray() | |
* Source: http://www.atwix.com/magento/custom-resource-model-magento-product-flat-tables/ | |
*/ | |
class Company_Custom_Model_Resource_Flat extends Mage_Core_Model_Resource_Db_Abstract | |
{ | |
protected $_storeId; | |
protected function _construct() | |
{ | |
$this->_init('catalog/product_flat', 'entity_id'); | |
$this->_storeId = (int)Mage::app()->getStore()->getId(); | |
} | |
public function getData($entityId) | |
{ | |
$resource = Mage::getSingleton('core/resource'); | |
$select = $resource->getConnection('core_read')->select(); | |
$select | |
->from($this->getTable(array('catalog/product_flat', $this->_storeId)), '*') | |
->where('entity_id = :entity_id'); | |
$result = $resource->getConnection('core_read')->fetchAll($select, array('entity_id' => $entityId)); | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment