Created
November 24, 2014 12:58
-
-
Save herveguetin/66d5663fd911f1f6889e to your computer and use it in GitHub Desktop.
When using Magento EE, and especially when flat category is active, requesting the "url_key" attribute for a category fails because it is not populated in catalog_category_flat_store_*. This method fixes that.
This file contains 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 category URL key for Enterprise | |
* | |
* @param Mage_Catalog_Model_Category $category | |
* @return string | |
*/ | |
public function getEnterpriseUrlKey(Mage_Catalog_Model_Category $category) | |
{ | |
$resource = Mage::getSingleton('core/resource'); | |
$conn = $resource->getConnection('core_read'); | |
$tableName = $resource->getTableName(array('catalog/category', 'url_key')); | |
$select = $conn->select() | |
->from( | |
array('url_key_table' => $tableName), | |
array('url_key' => 'url_key_table.value', 'store_id' => 'MAX(url_key_table.store_id)') | |
) | |
->where('url_key_table.entity_id = ?', $category->getId()) | |
->where('url_key_table.store_id IN(?)', array(Mage_Core_Model_App::ADMIN_STORE_ID, $category->getStoreId())) | |
; | |
$row = $conn->fetchRow($select); | |
return $row['url_key']; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment