0

We'd like to use the category thumbnail and text as brand info to show the logo and description on the product page. How can I get these information on the product page?

I'm working in: .../template/catalog/product/view.phtml

3 Answers 3

1

This approach didn't work for me because:

A product can be in several categories, so when you route to the product directly, it doesn't know the category. It's easy if you don't put products in more categories but more complex if you do.

I solved the problem with this answer: https://stackoverflow.com/questions/15735324/get-a-products-parent-category-even-if-it-is-accessed-directly

Here is my code to get the thumbnail image and description text even if a product is in more than one category (hope this helps others):

        <?php
            //load all categories where the product exists
            $cat = $_product->getCategoryCollection()->addAttributeToSelect('*');
            foreach($cat as $category){
                //check if the categorie in the array has a thumbnail and desc. text
                if($category->getThumbnail() && $category->getDescription()){
                    echo '<div class="cd-brand-logo"><img src="' . Mage::getBaseUrl('media').'catalog/category/' . $category->getThumbnail() .'" alt="' . $category->getName() . ' logo"></div>';
                    echo '<p>' . $category->getDescription() . '</p>';
                    // exit the loop if success
                    break; 
                }
                else{
                    echo '<p>Thumbnail or description is missing here.</p>';
                }
            }
        ?>
0
0

try this might be help you

    If(Mage::registry('current_catgory')){
    $Cat=Mage::getModel('catalog/category')->load(Mage::registry('current_catgory'));
    $name=$Cat->getName();
$thum=  Mage::getBaseUrl('media').'catalog/category/'.$Cat->getData('thumbnail');
    }

This code is work if you coming to product page from category page

Let me know ,if you have any issue

1
  • Hey.is its works?
    – Amit Bera
    Sep 2, 2014 at 9:19
0

SOLVED

Show All category with thumbnail on homepage

Show All category with thumbnail on homepage

1
  • Posting the code as text, using the available code formatting tools, will be more valuable to future searchers than posting an image. The image isn't searchable, copy and pasteable, etc.
    – AreDubya
    Aug 20, 2015 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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