Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8896707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:08:41+00:00 2026-06-15T00:08:41+00:00

So there’s some code floating around that gets an individual subcategory’s image: foreach ($collection

  • 0

So there’s some code floating around that gets an individual subcategory’s image:

foreach ($collection as $cat){
    $cur_category = Mage::getModel('catalog/category')->load($cat->getId());
    $layer = Mage::getSingleton('catalog/layer');   
    $layer->setCurrentCategory($cur_category);
    $_img = $this->getCurrentCategory()->getImageUrl();
}

Where $cat is the subcategory I’m trying to get the image of. The problem I’m running in to – the images for the subcategories are all the same! The first image from the subcategories is the image that shows up on the page. The links and names are all correct though: (this is also in the for loop)

<div>
    <a href="<?php echo $helper->getCategoryUrl($cat);?>">
        <img src="<?php echo $_img; ?>" title="<?php $cat->getName() ?>"/>
        <cite><?php echo $cat->getName();?></cite>
    </a>
</div>

I’m making this modification in catalog/category/view.phtml. There’s a bit more to it than shown, but this is all the relevant information.

Edit

All categories have their own unique images, which are properly uploaded. They show in the admin correctly. Also, $cat->getId() is returning the correct id’s for the individual subcategories.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:08:42+00:00Added an answer on June 15, 2026 at 12:08 am

    @RandyHall, are your sure that $this->getCurrentCategory() will get the category from the same place as $layer->setCurrentCategory($cur_category); will set it to?

    Watch the source code here and here.
    As you can see category is set to the layer model and get returns category from registry(via call to block).

    So I would suggest you to do something like this:

    $_img = $layer->getCurrentCategory()->getImageUrl();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are some Magento Connect extensions that I find myself installing every time I
There are some stdlib functions that throw errors on invalid input. For example: Prelude>
There is my code that I want to alert test once when mousemove ,
There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column
There are a lot of blogs saying that a hasOwnProperty check should be used
There is a website called Gild.com that has different coding puzzles/challenges for users to
There's a thrird party app that needs to get information via custom http headers,
There's a column on one of my tables that's being updated by various INSERT/DELETE
There was a smbmrx sample code using RDBSS in WDK Vista. But since WDK

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.