Sharing is helping.

We offer you this space to share your knowledge about Magento and learn from our experienced customers.

    Home Forums "How do I" questions Add CMS pagelink to topmenu Reply To: Add CMS pagelink to topmenu



    Thank you for the blog!Probably following code will help sooemne to show products randomly from a particular category:We need to write code for home cms like:{{block type= catalog/product_list category_id= 50 template= catalog/product/list_home.phtml }}Code: ?php$_productCollection=$this- getLoadedProductCollection();$categoryID = $this- category_id;//$categoryID = $this- getCategoryId();if($categoryID){ $category = new Mage_Catalog_Model_Category(); $category- load($categoryID); // this is category id $collection = $category- getProductCollection();} else{ $collection = Mage::getResourceModel(‘catalog/product_collection’);}Mage::getModel(‘catalog/layer’)- prepareProductCollection($collection);$collection- getSelect()- order(‘rand()’);$collection- addStoreFilter();$numProducts = $this- getNumProducts() ? $this- getNumProducts() : 1;$collection- setPage(1, $numProducts)- load();$_productCollection = $this- _productCollection = $collection;? ?php if(!$_productCollection- count()): ? div class= note-msg ?php echo $this- __(‘There are no products matching the selection. Please provide a category ID.’) ? /div ?php else: ? ul ?php $_collectionSize = $_productCollection- count() ? ?php foreach ($_productCollection as $_product): ? li a href= ?php echo $_product- getProductUrl() ? title= ?php echo $this- htmlEscape($_product- getName()) ? img src= ?php echo $this- helper(‘catalog/image’)- init($_product, ‘small_image’)- resize(105, 105); ? width= 105 height= 105 alt= ?php echo $this- htmlEscape($_product- getName()) ? / /a /li ?php endforeach ? /ul ?php endif; ? This code displays a single product.