cancel
Showing results for 
Search instead for 
Did you mean: 

Question about Product Filters widget

Question about Product Filters widget

I am testing my Magento development chops using a theme, and I wanted to have a filter that shows products from a particular brand. There is already a widget for showing "new_products" to show.

 

What I am trying to figure out is what causes the script to pull in a particular product type. Here is the code for pulling in the widget through CMS:

 

<div class="new_product">{{widget type="filterproducts/list" type_filter="new_products" column_count="4" limit_count="4" thumbnail_width="150" thumbnail_height="150" template="custom_template" custom_theme="filterproducts/new_products_home.phtml"}}</div>

Now when I pull up that new_products_home.phtml file I see:

 

<?php
    $_productCollection=$this->getProductCollection();
    $_helper = $this->helper('catalog/output');
    $_collectionSize = $_productCollection->count();
    $_columnCount = $this->getColumnCount();
	$thumbnailWidth = $this->getThumbnailWidth();
	$thumbnailHeight = $this->getThumbnailHeight();
?>
<?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 $i=0; foreach ($_productCollection as $_product): ?>
		<?php if ($i++%$_columnCount==0): ?>
        <ul class="products-grid">
        <?php endif ?>
            <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
                <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($thumbnailWidth,$thumbnailHeight); ?>" width="<?php echo $thumbnailWidth;?>" height="<?php echo $thumbnailHeight;?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
                <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>
                <!--span class="sku"><?php //echo $_product->getSku() ?></span-->
				<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                <?php echo $this->getPriceHtml($_product, true) ?>
                <div class="actions">
                    <?php if($_product->isSaleable()): ?>
                        <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                    <!--ul class="add-to-links">
                        <?php //if ($this->helper('wishlist')->isAllow()) : ?>
                            <li><a href="<?php //echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php // echo $this->__('Add to Wishlist') ?></a></li>
                        <?php //endif; ?>
                        <?php //if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                            <li><span class="separator">|</span> <a href="<?php //echo $_compareUrl ?>" class="link-compare"><?php //echo $this->__('Add to Compare') ?></a></li>
                        <?php //endif; ?>
                    </ul-->
                </div>
            </li>
        <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
        </ul>
        <?php endif ?>
	<?php endforeach ?>
	<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
</div>
<?php endif; ?>

Although it is not pulling in REAL products from the theme, can someone help me with learning how to pull in specific brands? Where do I setup the brands? How does it become a "filter" and how would it work with this script?

 

I appreciate the help! Man Happy

1 REPLY 1

Re: Question about Product Filters widget

Pass the brand id in widget as brand_id="150". To access this in phtml file, put code $this->getBrandId(). But you need to filter collection with conditions based on this to get proper result.