please how can i display the last 20 products, i created a category and i named it new arrivals on the settings i used a static block that i created with this code {{block type="catalog/product_list" category_id="2" mode="latest" template="catalog/product/list.phtml"}}
but it does not display the latest products. i dont know if it is from "my catalog/product_list" file
Please open new_product.phtml file from the below path and follow the further steps:
app\design\frontend\mypackage\mytheme\template\catalog\product\new_product.phtml
Step1: Please the below code.
<?php $products_count = $this->getData('products_count'); ?> <div class="anyClass"> <?php $i = 0; ?> <ul> <?php $collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToSort('created_at', 'DESC'); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection); foreach($collection as $_product) { ?> <li> <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(85) ?>" width="85" height="85" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a> <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"> <?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName()) ?> </a> </li> <?php $i++; if($i >= $products_count) break; ?> <?php } ?> </ul> </div>
Step 2: Goto Admin CMS >> Pages and select your Home Page, add the below code to your cms page content tabs.
{{block type="catalog/product_list" products_count="20" template="catalog/product/new_product.phtml"}}
Let me know if you face any query/concern regarding this.