php - Magento - Get Products from Specific Category -
i using following code display 4 products in random order. works, i'd limit results particular category or array of categories. how go implementing change?
thanks!
<?php $products = mage::getmodel('catalog/product')->getcollection(); $products->addattributetoselect(array('name', 'thumbnail', 'price')); //feel free add other attribues need. mage::getsingleton('catalog/product_status')->addvisiblefiltertocollection($products); mage::getsingleton('catalog/product_visibility')->addvisibleincatalogfiltertocollection($products); $products->getselect()->order('rand()'); $products->getselect()->limit(4); foreach ($products $product) : ?> <div class="three columns"> <div class="product_container "> <div class="feat_prod_cont"> <h4 class="feature_product_title"><a href="<?php echo $product->getproducturl()?>"><?php echo $product->getname()?></a></h4> <a href="<?php echo $product->getproducturl()?>"><img class="thumbnail" src="<?php echo mage::helper('catalog/image')->init($product, 'thumbnail')->resize(93, 100)?>" alt=" "></a> <div class="prod_details_featured"> <h3 class="price">$199.99</h3> free shipping free stove </div> <div class="buy_btn"><a href="<?php echo mage::helper('checkout/cart')->getaddurl($product); ?>">add cart</a></div> </div> </div> </div> <?php endforeach; ?>
Comments
Post a Comment