If you ever need listing the newest products of magento current category (or even of a category given by it’s Id, see the code comments)
<?php $totalPerPage = ($this->show_total) ? $this->show_total : 9; $visibility = array( Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG ); // If you want to use a specific category load it by using this // $cur_category=Mage::getModel('catalog/category')->load($category_id); // Get current category $cur_category = Mage::registry('current_category'); $storeId = Mage::app()->getStore()->getId(); $_productCollection = Mage::getResourceModel('catalog/product_collection')->setStoreId($storeId) ->addAttributeToSelect('*') ->addStoreFilter($storeId) ->addCategoryFilter($cur_category) ->addAttributeToFilter('visibility', $visibility) ->setOrder('created_at', 'desc') ->setPageSize($totalPerPage); ?> |
For a client website, they needed to display their newest products on their own page. To do this I created a new CMS page entitled, go figure, “New Arrivals”. Using the ‘custom design’ options that Magento affords for each CMS page I added a block to pull all the products that are marked as ‘new’. To mark a product as new one must have set a date for the “Set Product as New from Date” and “Set Product as New to Date” options in the “General” product information page in the admin. Failure to mark these will keep the block from displaying anything at all.
Hi gold price!
I hope your first intent was not to sindicate your link
Yea that’s another way to solve it by inserting in html mode in cms page editor the code for block {{block type=”catalog/product_new” name=”home.catalog.product.new” alias=”product_homepage” template=”catalog/product/new.phtml”}} which will give you all the new products while mine post referred to new products in the context of a category.
Magento wiki describes it.
http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page