3

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();
asked Apr 14, 2017 at 8:22
2
  • 3
    Please don't post non-answers to try to bump the question. That's an abuse of the system. Commented Apr 19, 2017 at 14:35
  • 1
    You can find answer by link stackoverflow.com/questions/11719296/… Commented Apr 19, 2017 at 16:28

1 Answer 1

0

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.

  1. Create a Static CMS block with your image in it. Menu Item CMS -> Static Blocks
  2. Update the Display Settings for the category where you want to image to appear and add the block.

Here is the navigation:

  1. Catalog -> Manage Categories
  2. Select The category you want to update
  3. Select the Display Settings Tab
  4. Set the Display Mode to Static Block and Products
  5. 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.

Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
answered Feb 8, 2018 at 2:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.