2

I have a problem customizing a Magento page.

Categories (example): Default Category (0) - Products (9) - High Bay (0)

In directory -> public_html/app/design/frontend/template/default/template/page/list.phtml

list.phtml (code below)

    $_category = Mage::getModel('catalog/category');  
            $_categories = $_category
            ->getCollection()
            ->addAttributeToFilter('level', 3)
            ->addAttributeToSelect("*");

            foreach ($_categories as $_category){
                //print_r($_category);
                //die(0);
                echo $_category->getThumbnail().'   ';
                echo $_category->getName().'   ';
            }
                ?>

Can I ask users here how do I retrieve and display an image and create a link to respective category products? I am getting only image name with no image display.

Thank you.

0

$_category->getThumbnail() is give image path from media/catalog.

If you want full image then you need append Media catalog path in you image url

Mage::getBaseUrl('media').'catalog/category/'.$_category->getThumbnail()

Full code:

<img src="<?php eccho Mage::getBaseUrl('media').'catalog/category/'.$_category->getThumbnail()?>"  alt="<?php echo $_category->getName();?> "/>
8
  • Thank you for your suggestion. I append but it does not show me the image, am I doing it wrong?
    – Enthu
    Nov 25 '14 at 3:55
  • is $_category->getThumbnail() give any data?
    – Amit Bera
    Nov 25 '14 at 4:46
  • Yes, I have uploaded a category image to test out the result. It is returning a filename (ex. bulb.png)
    – Enthu
    Nov 25 '14 at 4:54
  • Here you upload this.. Can you please give me screen shot
    – Amit Bera
    Nov 25 '14 at 5:01
  • sorry,i want to screen of category at admin
    – Amit Bera
    Nov 25 '14 at 6:32

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.