I have just created a custom attribute for categories through Attribute Manager, with attribute code category_view_img.

Now I can only put one image into a category, and use this image for both the banner and category-view-image on the home page. I want to use this custom attribute image on the home page as category view image. How can I get this image on front-end?

I am new to Magento and I don't have ideas how to do this, please assist. I am using Magento

| improve this question | | | | |

Use below code:

<?php $category = Mage::getModel('catalog/category')->load('category-id'); ?>
<img src="<?php echo $category->getCategoryViewImg(); ?> />
| improve this answer | | | | |
  • Thanx For Your Reply @Prashant, I have tried this, But its not working. Maybe there is any other way to getData from Catergory Attributes. – Lalit838 May 9 '16 at 6:53

After spinning my head regularly throughout all over Internet, I finally found a solution for this issue:

var $image= trim(Mage::getBaseUrl('media').'catalog/category/'.$_category->getData('category_view_img'));

<img src="<?php echo $image;?>"/>

I hope this helps someone.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.