I want to add a picture on top of category name in frontend. I tried creating a custom field for the category and adding a picture that way. I can see the custom field from admin, but I can't see anything I type in the custom textarea on my frontend category name. I tried flushing cache and reindexing data. I also tried adding in app/design/frontend/package/theme/template/catalog/category/view.phtml this code:
<?php if($_customAttribute = $this->getCurrentCategory()->getCustomAttribute()): ?>
<?php echo $_helper->categoryAttribute($_category, $_customAttribute, 'custom_attribute') ?>
<?php endif; ?>
But when i added it all my products disappeared and I still coundn't see changes to my category name.
Atwix_CustomCategoryAttribute.xml
<?xml version="1.0"?>
<config>
<modules>
<Atwix_CustomCategoryAttribute>
<active>true</active>
<codePool>local</codePool>
</Atwix_CustomCategoryAttribute>
</modules>
</config>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Atwix_CustomCategoryAttribute>
<version>0.0.1</version>
</Atwix_CustomCategoryAttribute>
</modules>
<global>
<resources>
<add_category_attribute>
<setup>
<module>Atwix_CustomCategoryAttribute</module>
<class>Mage_Catalog_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</add_category_attribute>
<add_category_attribute_write>
<connection>
<use>core_write</use>
</connection>
</add_category_attribute_write>
<add_category_attribute_read>
<connection>
<use>core_read</use>
</connection>
</add_category_attribute_read>
</resources>
</global>
</config>
mysql4-install-0.0.1.php
<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'custom_attribute', array(
'group' => 'General Information',
'input' => 'textarea',
'type' => 'text',
'label' => 'Custom attribute',
'backend' => '',
'visible' => true,
'required' => false,
'visible_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));
$this->endSetup();
-
3Please don't post non-answers to try to bump the question. That's an abuse of the system.user53245– user532452017年04月19日 14:35:39 +00:00Commented Apr 19, 2017 at 14:35
-
1You can find answer by link stackoverflow.com/questions/11719296/…Vadym Kalin– Vadym Kalin2017年04月19日 16:28:28 +00:00Commented Apr 19, 2017 at 16:28
1 Answer 1
It does not seem that programming is necessary to add an image above the items in a category. Here is a simple solution that may meet your requirements.
- Create a Static CMS block with your image in it. Menu Item CMS -> Static Blocks
- Update the Display Settings for the category where you want to image to appear and add the block.
Here is the navigation:
- Catalog -> Manage Categories
- Select The category you want to update
- Select the Display Settings Tab
- Set the Display Mode to Static Block and Products
- Set the CMS Block to the Static Block you created for the category.
That's it you are done. Maybe clear the cache if you change does not appear immediately.
Magento is very versatile out of the box with lots of built-in features.
Explore related questions
See similar questions with these tags.