Newcastlefan
Newcastlefan

Reputation: 39

Magento home page popular products

Hi All I want to show 4 popular products on the home page of my magento 1.7.1 install. (The I can select by putting them into a category).

I've set this up by creating a hidden category called popularhome and added 4 products into it.

I've included this in a static block into my home page template by using:

{{block type="catalog/product_list" column_count="4" category_id="17" template="catalog/product/listhome.phtml"}}

My listhome.phtml template looks like this:

<div class="row popularproducts">

<?php
    $_productCollection=$this->getLoadedProductCollection();
    $_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<div class="alert fade in">
  <a class="close" data-dismiss="alert">×</a>
  <?php echo $this->__('There are no products matching the selection.') ?>
</div>
<?php else: ?>
    <?php // List mode ?>
    <?php if($this->getMode()!='grid'): ?>
    <?php $_iterator = 0; ?>
    <?php else: ?>
    <?php // Grid Mode ?>
    <?php $_collectionSize = $_productCollection->count() ?>
    <?php $_columnCount = $this->getColumnCount(); ?>
    <?php $i=0; foreach ($_productCollection as $_product): ?>
        <?php if ($i++%$_columnCount==0): ?>
            <?php endif ?>
            <div class="c3">
            <?php if(($i-1)%$_columnCount==0): ?><?php elseif($i%$_columnCount==0): ?><?php endif; ?>
                <div class="thumbnail">
                <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image thumbnail"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(225); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>

                <div class="caption">
                    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
                    <?php if($_product->getRatingSummary()): ?>
                    <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                    <?php endif; ?>
                    <?php echo $this->getPriceHtml($_product, true) ?>
                </div>
                </div>
                </div>

            <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>


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


<?php endif; ?>

</div>

However this is only showing 2 of the 4 products yet I cannot figure out why? Does anyone see anything I am missing?

Thanks!

Upvotes: 2

Views: 2090

Answers (1)

liyakat
liyakat

Reputation: 11853

First you need to check ,the products that you want to be appear in category page,

Is they really belong to that categories.

After that make sure Backend > Manage Categories > Edit categories > Display settings >

is Anchor = yes Then re-index your catalog.

To verify you need to cross check catalog_category_product and catalog_category_product_index.

If the category id and product id is mapped properly in these tables you should be good to go.

hope this will sure help you!

Upvotes: 1

Related Questions