i am using magento enterprise edition, i have created a module to add custom attributes to the categories , the attributes are visible in adminhtml and they are saved propertly but when i try to retrieve the category on frontend, it doesnot contain the attributes i just created and i alredy reindex all but nothing, the problem is magento enterprise because i tried in magento community and works fine, here is my code
$installer = Mage::getResourceModel('catalog/setup','catalog_setup');
$installer->startSetup();
$label="whatever";
$installer->addAttribute('catalog_category', $label, array(
'type' => 'int',
'label' => $label,
'input' => 'select',
'source' => 'eav/entity_attribute_source_boolean',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'default' => '0',
"visible_on_front" => true,
'group' => 'filter9',
));
here is the config file
<?xml version="1.0"?>
<config>
<modules>
<Qxd_Categories>
<version>0.0.6</version>
</Qxd_Categories>
</modules>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Qxd_Categories before="Mage_Adminhtml">Qxd_Categories_Adminhtml</Qxd_Categories>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<global>
<resources>
<qxd_categories_setup>
<setup>
<module>Qxd_Categories</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</qxd_categories_setup>
<qxd_categories_setup_write>
<connection>
<use>core_write</use>
</connection>
</qxd_categories_setup_write>
<qxd_categories_setup_read>
<connection>
<use>core_read</use>
</connection>
</qxd_categories_setup_read>
</resources>
</global>
</config>
And this is front end where i am trying to reindex data and retrieve the category:
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*');
$process = Mage::getModel('index/process')->load(5); $process->reindexAll();
$process = Mage::getModel('index/process')->load(6); $process->reindexAll();
foreach ($categories as $category) {
$cat = Mage::getModel("catalog/category")->load($category->getId());
if($cat->getData('entity_id')=='7'){
var_dump($cat->getData()); // all but my attribute
var_dump($cat); // my attribute is not there :(
var_dump($cat->getName()); // My Category Name
}
}
Any suggestion is welcome, please help me!!
Best Answer
Your attribute code is whatever when you can this field by
$cat->getWhatever();
If this attribute is what_ever the_ (underscore make next letter of capital)
thus