1 Comment

Fetch Category Image

Issues with payments in admin on 1.9.2.4
Seller Following Not working

I am attempting to display all sub-categories of a parent category on a static block page (e.g. brands will show all sub-categories such as Adidas, Nike etc.). I am having problems at the moment calling the category image. It is the category image I am looking for and not the thumbnail.

Here’s my code:

                    <?php 
                    //If there are sub categories
                    $categories = $this->getCurrentChildCategories();
                    $categoriescount = $this->getCurrentChildCategories()->count();
                    if ($categoriescount > 0): 
                    ?>
                    <div class="sub-category-container">    
                        <?php 
                        //Loop through categories
                        foreach ($categories as $category):
                        ?>
                        <div class="sub-category">
                            <a href="<?php echo $this->getCategoryUrl($category)?>" class="cat-image">
                            <?php 
                            // If there is a thumbnail set for the category - Display it
                            if($imgUrl = Mage::getModel('catalog/category')->load($category->getId())->getThumbnail()):?>
                            <img src="<?php echo $this->getBaseUrl()."media/catalog/category/".$imgUrl ?>" width="220" height="110" alt="<?php echo $this->htmlEscape($category->getName()) ?>" />
                            <?php endif; ?>
                            </a>
                            <div class="inner-sub-category">
                                <a href="<?php echo $this->getCategoryUrl($category)?>" class="sub-link"><?php echo $category->getName()?></a>
                                <a href="<?php echo $this->getCategoryUrl($category)?>" class="btn"><span>View All</span></a>
                            </div>
                        </div>

                        <?php endforeach; ?>
                    </div>
                    <?php else:?>
                    <p>No Sub Categories</p>
                    <?php endif; ?>

Related Posts

  • Link to product or listing dependent on number of products in catergory (0)
    I have the following code that pulls sub-categories of the parent categories into a static block. I would like to adapt the code so that the link generated if the sub-category contains > 1 product is the cat url. If there is only 1 product in the category the link generated should […]
  • Magento 1.9.2.4 sub-category listing not working (1)
    I managed to get sub-categories showing on the category page with images, but now since updating 1.9.2.1 up to 1.9.2.4 it no longer works. I cant imagine what may have changed and haven't altered anything. I followed this […]
  • Sorted subcategory list with thumbnails (1)
    I have the following block: <div id="home-subcat-container"> <div class="wallcontainer"> <?php //gets all sub categories of parent category 'Brands' $cats = Mage::getModel('catalog/category')->load(3)->getChildren(); $catIds = explode(',',$cats); […]
  • Positioning static blocks side by side on a cms page (1)
    First of all I should say I am not a web designer because I think my problem is really simple to solve but I don't know how: I created static blocks with these images but I can't bring it to this position.
  • Calling 'layered navigation' attributes into a static block (1)
    So to explain what i'm trying to do: I want to take my filterable results such as brand or product type that you would find in the left navigation to a static block. I'm no coder, but I figured I was in the right area using code like this inside a static block. <reference […]
  • Email logo/img is not loading (0)
    i have a problem with my transaction transactional emails. Im using Magento 2 at the moment and i am creating some transaction emails to learn.... now i need to load an img in the email and it is not showing up, i am loading my images via […]
  • Show single product in category description area (0)
    I want to add a single product with product ID in category description area. THE product will contain only product image, name and link to product view. Is there any way like we add product link in static block with the help of widget?
  • How do I hide a static block on one of my category product pages? (1)
    On all my product pages just below the main product images I have a static block called "block_product_img_bottom", which contains a small image. All but one category must display this image, so how do I hide this static block on just one of my categories?
  • When category is x and y show static block on product detailpage (0)
    I would like to show a static block on some of my product pages. Lets say when a category is 5 and 8 then show static-block "special-terms" on all of the product pages which are in this categories. How can I do this? /catalog/product/view.phtml
  • How to add a category column in custom orders report Grid, separated by items (0)
    I'm trying to do a custom order report, I need to show each item in the order separately, that is not the problem, but this is: I have a category called 'Brand', and a few subcategories of that, whit the name of brands, I have attached each single product to a single brand […]
Issues with payments in admin on 1.9.2.4
Seller Following Not working

1 Comment on this article

  • User November 12, 2016

    It was as simple as changing this line from ‘Thumbnail’ to ‘Image’:

     if($imgUrl = Mage::getModel('catalog/category')->load($category->getId())->getImage()):?>
    

    Reply

Add a comment