I am trying to create a module so that you can define a custom url for the navigation menu. I am trying to link to a non CMS page created by another extension. I was able to create the custom attribute for the category and it shows in admin but when I try to extend "Mage_Catalog_Model_Category" to overwrite the "getUrl" function, I am not able to access my new custom attribute. See below for code. I just want to use the "custom_category_url" if there is a value otherwise fallback to the parent getUrl function, but currently $this->getData('custom_category_url') is always returning NULL. I assume I need to do something so that the attribute is available at this point but I am not sure how. Full code is available at https://github.com/americanstationery/AmstatCustomUrl.
<?php
class Amstat_CustomUrl_Model_Category extends Mage_Catalog_Model_Category
{
/**
* Get category url
*
* @return string
*/
public function getUrl()
{
$categoryRedirectUrl = $this->getData('custom_category_url');
if(strlen($categoryRedirectUrl) > 0 && $categoryRedirectUrl != '0'){
return $categoryRedirectUrl;
}
return parent::getUrl();
}
}