This is the code that we can use to check whether the product is bundle or not
if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
echo 'Bundled';
}
So you need to use the above code, as your need. For example, if you put this code inside loop,it will not render bundle product view.
<?php foreach ( $_products as $_product ) : ?>
if (!$_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
<li class="clearfix">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgX, $imgY) ?>" data-srcX2="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($imgX*2, $imgY*2) ?>" width="<?php echo $imgX; ?>" height="<?php echo $imgY; ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</a>
<div class="product-info">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a>
<?php echo $this->getPriceHtml($_product, true) ?>
</div>
</li>
<?php } ?>
So use that condition according to your need in the template file.
Note: Do not edit core template files directly
EDIT
According to my friend @Marius, my answer seems to be incomplete. So this is an attend to present what happens this page really
The method that we are interested here is $this->getRecentlyViewedProducts()
. If this provide an empty value, that means the template content will not be rendered in frontend. Let us look what this call provide us. Take a look on Mage_Reports_Block_Product_Viewed::_toHtml()
method.
protected function _toHtml()
{
if (!$this->getCount()) {
return '';
}
$this->setRecentlyViewedProducts($this->getItemsCollection());
return parent::_toHtml();
}
_toHtml()
is a special method, that will invoke by Magento automatically in order to render the content of that block. Since this method is defined for recent viewed products block, that means this block get automatically rendered during page loading. Here you can see that the method sets a value recently_view_products
using this call $this->setRecentlyViewedProducts($this->getItemsCollection());
. This is what we actually obtain in template file. So let us look what getItemsCollection()
provides. It is defined in Mage_Reports_Block_Product_Abstract
block class. The method shown below
public function getItemsCollection()
{
if (is_null($this->_collection)) {
$attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
$this->_collection = $this->_getModel()
->getCollection()
->addAttributeToSelect($attributes);
if ($this->getCustomerId()) {
$this->_collection->setCustomerId($this->getCustomerId());
}
$this->_collection->excludeProductIds($this->_getModel()->getExcludeProductIds())
->addUrlRewrite()
->setPageSize($this->getPageSize())
->setCurPage(1);
/* Price data is added to consider item stock status using price index */
$this->_collection->addPriceData();
$ids = $this->getProductIds();
if (empty($ids)) {
$this->_collection->addIndexFilter();
} else {
$this->_collection->addFilterByIds($ids);
}
$this->_collection->setAddedAtOrder();
if ($this-> _useProductIdsOrder && is_array($ids)) {
$this->_collection->setSortIds($ids);
}
Mage::getSingleton('catalog/product_visibility')
->addVisibleInSiteFilterToCollection($this->_collection);
}
return $this->_collection;
}
The important part of this method is this snippet
$this->_collection = $this->_getModel()
->getCollection()
->addAttributeToSelect($attributes);
This is the collection method used by this method. Further inspection reveals that, the model that get loaded here is Mage_Reports_Model_Product_Index_Viewed
. Take a look on this Model class. You can see a unique method that is defined there. It is given below.
public function getExcludeProductIds()
{
$productIds = array();
if (Mage::registry('current_product')) {
$productIds[] = Mage::registry('current_product')->getId();
}
print_r($productIds);
return $productIds;
}
As the name specifies, this method is use to exclude some product ids. Currently this method only excludes product that is currently viewing by the user. You can also see that, following filtering is applying in getItemsCollection()
method also.
$this->_collection->excludeProductIds($this->_getModel()->getExcludeProductIds())
->addUrlRewrite()
->setPageSize($this->getPageSize())
->setCurPage(1);
So this is the perfect place to apply alternation in this case. What we need to do is, we need to fill the array that holds excluding product ids with bundle product ids also.
What we need to do here
Thus we need a simple model rewrite in order to achieve the result. Our rewriting model has a getExcludeProductIds()
method that should define like this.
public function getExcludeProductIds()
{
$productIds = array();
//get all collection
$collection = $this->getCollection();
foreach ($collection->getItems() as $item) {
//check for bundle product, if yes add it to excluding id array
if($item->getTypeId() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE ){
$productIds[] = $item->getId();
}
}
if (Mage::registry('current_product')) {
$productIds[] = Mage::registry('current_product')->getId();
}
print_r($productIds);
return $productIds;
}
As you can see, along with current product that is viewing by user, the excluding id array ($productIds
) now holds bundle product ids also. Thats it.
Note: Again do not edit core files. You need to rewrite this model class