I want to show some specific product on product listing page :
like product_collection.phtml
there is a code that grab the collection
$_productCollection=$this->getLoadedProductCollection();
It show all products in particular category but I want to show few product by there ids may be array of product ids like
$productids=array(11,22,1,4);
how can I do that add filter or any other way ?..
i tried below code but it is not working . code of product_collection.phtml:
<?php
/* added code for filter start */
$productIds = array(1,3,2);
$_productCollection=$this->getLoadedProductCollection()->addAttributeToFilter('entity_id', array('in' => $productIds));
/* added code for filter ends */
/*order code
$_productCollection=$this->getLoadedProductCollection();
*/
$_helper = $this->helper('catalog/output');
?>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = !empty($cols)?$cols:$this->getColumnCount(); ?>
<div class="category-products">
<?php echo $this->getToolbarHtml(); ?>
<div class="products-block" id="products-grid">
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<div class="row products-grid">
<?php endif ?>
<?php echo $_product->getName().'<br>';?>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</div>
<?php endif ?>
<?php endforeach ?>
<script type="text/javascript">decorateGeneric($$('div.products-row'), ['odd','even','first','last'])</script>
</div>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>