I have a problem in view the products on the home page. more precisely, if I use this code:
$_productCollection=$this->getLoadedProductCollection();
I get the message "There are no products matching the selection."
but if I replace the above code with this:
$_productCollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('visibility', 4)->addAttributeToFilter('status', 1)->load();
I then displays all the products in the catalog, even though I specified on the home page, in this way, what category see more:
{{block type="catalog/product_list" category_id="24" template="catalog/product/list-home.phtml"}}
how can I fix it?
P.S. I have the same problem when I select a product category from the navigation bar.
Thanks in advance for the help.
**** EDIT ****
code that I use inside the CMS home page is:
{{block type="catalog/product_list" category_id="24" template="catalog/product/list-home.phtml"}}
code that use the file list-home.phtml is this:
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount();?>
<ul class="products-grid row">
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php /* if ($i++%$_columnCount==0): ?>
<ul class="products-grid row">
<?php endif */ ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first
<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?> col-sm-4 col-xs-6">
<div class="item-container img-thumbnail">
<div class="item-flipper">
<div class="item-front">
<!-- front content -->
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(250,310); ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="img-responsive" /></a>
</div>
<div class="item-back">
<!-- back content -->
<div class="book-info">
<div class="h4"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></div>
<div class="short-description"><?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></div>
</div>
<p><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="btn btn-block btn-success"><?php echo $this->__('Book Details')></a></p>
</div>
</div>
</div>
<h3 class="panel-title 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></h3>
<div class="pull-left"> <?php echo $this->getPriceHtml($_product, true) ?> </div>
<div class="pull-right">
<?php if($_product->isSaleable()): ?>
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="btn btn-warning btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><?php echo $this->__('Add to Cart') ?></button>
<?php else: ?>
<p class="btn btn-alert availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
</div>
</li>
<?php if ($i==6) break; ?>
<?php /* if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif */ ?>
<?php endforeach ?></ul>
</div>
<?php endif; ?>
with the code above can not I see any product. if I replace the code that I said at the beginning, then I can see all the products, but I would like to display only those belonging to the category that I specified in the code of the home page.
I can not understand where I'm wrong.