Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Category-attributes in frontend? 
 
nanashidri
Jr. Member
 
Total Posts:  4
Joined:  2012-08-15
 

Hi all,

I’ve created a custom attribute for categories in Magento to use in one of the new page layouts that I’m making for a new category; but oddly enough, I’m not able to grab it to the frontend. I’ve been trying to find a solution for this since yesterday, to no avail.

I’ve seen multiple threads on different forums, including SO. I’ve tried multiple solutions. For example:

Mage::registry('current_category')->getAttributes()

And also the following:

Mage::getSingleton('catalog/layer')->getCurrentCategory()->getAttributes()

Which I believe does the same thing. The problem is, they both return the following error which I can’t seem to figure out:

Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Category_Flat::loadAllAttributes() in X:\xampp\htdocs\project\app\code\core\Mage\Catalog\Model\Category.php on line 289

Also, trying to var_dump getData() doesn’t return this attribute, even though it (the attribute) does exist in the backend under “Manage Categories”, and even though it can be modified and saved and remain the way it was last saved when you refresh the page. I’ve also tried multiple solutions that suggests using a loop to loop through all categories and grab the attributes; but that didn’t work either.

Printing the following:

Mage::registry('current_category')->debug()

As another thread adviced, didn’t return the attribute I’d created, but it returned the default attributes.

I’ve checked multiple sites to ensure that I didn’t miss anything critical during the creation of the attribute, and so far I’ve not found anything that I’ve missed.

When creating the attribute; the following parameters where used:

$this->addAttribute('catalog_category''used_by', array(
    
'group'         => 'General',
    
'input'         => 'textarea',
    
'type'          => 'text',
    
'label'         => 'Used by',
    
'backend'       => '',
    
'visible'       => true,
    
'required'      => false,
    
'wysiwyg_enabled' => true,
    
'visible_on_front' => true,
    
'is_html_allowed_on_front' => true,
    
'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));

My questions are:

- How do I grab the custom attribute that I made and use it in the frontend?
- What are the parameters that have to be there for the attribute to function properly in the backend and frontend?

Thanks in advance,
/Nanashi

 
Magento Community Magento Community
Magento Community
Magento Community
 
nanashidri
Jr. Member
 
Total Posts:  4
Joined:  2012-08-15
 

Finally, after spending approximately 15 hours on this, somebody told me to re-index.. And I did, and now it works.

Thanks though!
/Nanashi

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top