how to filter the products using code
<?php
$val=$_GET['advertiser_id'];
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*') // select all attributes
->setPageSize(30) // limit number of results returned
->setCurPage(4) // set the offset (useful for pagination)
->addAttributeToFilter('advertiser_name', array('finset' => $val));
// we iterate through the list of products to get attribute values
?>
<!--============================container-fluid=========================-->
<div class="item-main container-fluid">
<?php //echo $this->getPagerHtml(); ?>
<div class="row">
<?php
foreach ($collection as $product) {
?>
<div class="col-md-2">
<div class="border01">
<a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage(); ?>"/></a>
<div class="item-text1"> <?php echo $product->getName();?></div>
</div>
</div>
<?php
}
?>
$val=$_GET['advertiser_id'];
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*') // select all attributes
->setPageSize(30) // limit number of results returned
->setCurPage(4) // set the offset (useful for pagination)
->addAttributeToFilter('advertiser_name', array('finset' => $val));
// we iterate through the list of products to get attribute values
?>
<!--============================container-fluid=========================-->
<div class="item-main container-fluid">
<?php //echo $this->getPagerHtml(); ?>
<div class="row">
<?php
foreach ($collection as $product) {
?>
<div class="col-md-2">
<div class="border01">
<a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage(); ?>"/></a>
<div class="item-text1"> <?php echo $product->getName();?></div>
</div>
</div>
<?php
}
?>
Comments
Post a Comment