Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

When I upload an image for a category, it shows up in admin but not on the frontend … why? 
 
adam777
Member
 
Total Posts:  38
Joined:  2008-05-08
 

When I upload an image for a category, it shows up in admin but not on the frontend ... why? Is there a way to make it work?

I am now creating static blocks to call my category images, but I know this is not the right way to do it ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
rockbochs
Jr. Member
 
Total Posts:  11
Joined:  2008-06-28
 

Hi Adam, i’ve got the same issue.  I’ve referenced this thread:  http://www.magentocommerce.com/boards/viewthread/5026/P0/ , but it’s easy to get lost in all the code (and I would rather not start cutting/pasting code that I don’t understand).  Is this a pretty common problem across the board?  I’ve tried this code change, but it didn’t seem to fix anything: 

hyteckit - 20 July 2008 05:23 AM

This is a bug fix or update the Mage_Catalog_Block_Navigation class

Don’t bother messing with the layers object, and setting the current category to something else.  It will only get messy.

Just update the class “Mage_Catalog_Block_Navigation”.  File can get found under “code/core/Mage/Catalog/Block/Navigation.php”.

Add the following to the function “getCurrentChildCategories”:

->addAttributeToSelect('image')

so

public function getCurrentChildCategories()
    
{
        $layer 
Mage::getSingleton('catalog/layer');
        
$category   $layer->getCurrentCategory();
        
/* @var $category Mage_Catalog_Model_Category */
        
$collection Mage::getModel('catalog/category')->getCollection();
        
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
        
$collection->addAttributeToSelect('url_key')
            ->
addAttributeToSelect('name')
            ->
addAttributeToSelect('is_anchor')
            ->
addAttributeToFilter('is_active'1)
            ->
addIdFilter($category->getChildren())
            ->
joinUrlRewrite()
            ->
load();

        
$productCollection Mage::getResourceModel('catalog/product_collection');
        
$layer->prepareProductCollection($productCollection);
        
$productCollection->addCountToCategories($collection);
        return 
$collection;
    
}

becomes:
public function getCurrentChildCategories()
    
{
        $layer 
Mage::getSingleton('catalog/layer');
        
$category   $layer->getCurrentCategory();
        
/* @var $category Mage_Catalog_Model_Category */
        
$collection Mage::getModel('catalog/category')->getCollection();
        
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
        
$collection->addAttributeToSelect('url_key')
            ->
addAttributeToSelect('name')
            ->
addAttributeToSelect('image')
            ->
addAttributeToSelect('is_anchor')
            ->
addAttributeToFilter('is_active'1)
            ->
addIdFilter($category->getChildren())
            ->
joinUrlRewrite()
            ->
load();

        
$productCollection Mage::getResourceModel('catalog/product_collection');
        
$layer->prepareProductCollection($productCollection);
        
$productCollection->addCountToCategories($collection);
        return 
$collection;
    
}


Once you applied the fix, you have access to the functions “getURL()”, “getName()”, “getImageUrl()”, and “getData()” for any object Mage_Catalog_Model_Category.


For example, if you wanted the name of child category, url to the child category, and image of the child category:

$_categories=$this->getCurrentChildCategories();
if(
$_categories->count())
{
         
foreach ($_categories as $_category)
         
{
                
if($_category->getIsActive())
                
{
                    $_category_data 
$_category->getData();
                    echo 
$_category->getURL();
                    echo 
$_category->getImageUrl();
                    echo 
$_category->getName();
                 
}
         }
}

Anyone have any idea?

 
Magento Community Magento Community
Magento Community
Magento Community
 
rockbochs
Jr. Member
 
Total Posts:  11
Joined:  2008-06-28
 

FYI, I upgraded to the newest version of Magento 1.1 as per this link:  http://www.magentocommerce.com/blog/comments/magento-11-is-here-1/ and it fixed my issue.

 
Magento Community Magento Community
Magento Community
Magento Community
 
advinsteven
Jr. Member
 
Total Posts:  4
Joined:  2012-02-15
 

If you use big images, try to increase ‘memory_limit’ parameter in your ‘php.ini’ file.

 
Magento Community Magento Community
Magento Community
Magento Community
 
advinsteven
Jr. Member
 
Total Posts:  4
Joined:  2012-02-15
 

If you use big images, try to increase \\\’memory_limit\\\’ parameter in your \\\’php.ini\\\’ file.

Term paper Writing
Term paper Writing Services

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top