I would like to display my "Products" category items on my homepage for https://cashino.kellyseye.com/

The "home-page-main-content" static block contains the following code:

{{block type="core/template" name="home-page-center" as="home-page-center" template="homepage/home.phtml"}}

"home.phtml" contains the following code:

<div class="home-category">
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_rootCategories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>

if (count($_rootCategories) > 0):
$_columnCount = 3;?>

<?php foreach ($_rootCategories as $_rootCategory)
        <?php $_rootCategory = Mage::getModel('catalog/category')->load($_rootCategory->getId()); ?>
        <?php $_categories = $_rootCategory->getChildrenCategories(); ?>
        <?php $i=0;?>
        <?php foreach($_categories as $_category):
                $_categoryDetail = Mage::getModel('catalog/category')->load($_category->getId());

        <?php if($i%($_columnCount) == 0) { ?>
            <ul class="products-grid-home cf">
        <?php }

          $class = 'item last';
          $class= 'item';
            <a href="<?php echo $_helper->getCategoryUrl($_categoryDetail) ?>">
                <li class="<?php echo $class;?>" style="background: #fff; background-image: url('<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/category/'.$_categoryDetail->getImage()?>'); background-size: cover; background-repeat: no-repeat;">
                    <span class="home-cat-anchor">
                        <span><?php echo $_categoryDetail->getName() ?></span>
                        <?php if($_categoryDetail->getDescription() != "") { ?>
                            <p class="cat-desc-dropdown">
                                $desc = strip_tags($_categoryDetail->getDescription());
                                if (strlen($desc) > 200) {
                                    // truncate stringstring
                                    $stringCut = substr($desc, 0, 200);
                                    // make sure it ends in a word so assassinate doesn't become ass...
                                    $desc = substr($stringCut, 0, strrpos($stringCut, ' ')).'...';
                                echo $desc;
                        <?php } ?>

            if ($i % ($_columnCount) == 0 || ($i == count($_categories))) {?>
            <?php }?>

        <?php endforeach; ?>
<?php }?>
<?php endif; ?>

I would like to keep this as it is displaying the products on https://store.kellyseye.com/ perfectly.

Please help!

  • You cannot show this as your code says you are using current category from registry and in homepage you will not get that variable so better to use new code for your homepage. – Sukumar Gorai Sep 6 '18 at 14:48
  • I have to idea how to do this. I still want to display the products that are on the store.kellyseye.com homepage. But for the cashino.kellyseye.com homepage i'd like to show the products that are under the products tab. – Jordan C Sep 6 '18 at 14:59

Your code is correct. Just assign some products to your categories, then the category items will be visible in the homepage.

Except this line:

<?php $currentCategory = Mage::registry('current_category') ?>

You need to remove it. It is useless since current_category registry is not available on homepage.

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.