Reputation: 1
I don't how to show special priced(sale on it)products in magento home page .I tried a lot but it can't...
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}
this is also not working.
Upvotes: 0
Views: 6922
Reputation: 21
You can use an extension its free of cost URL: http://www.magentocommerce.com/magento-connect/top-seller-new-feature-most-viewed-catalog-sale-recently-ordered-all-products-7-in-one-catalog-by-etatvasoft.html. Go TO system >> Configuration >> Tatvasoft >> Catalog Extensions Configuration >> Feature You Want >> Enable >> Yes It will show sale products in featured product and sale in category in promotional. Also dont forget to add these lines in cms>pages>home
To see Bestsellers products
{{block type="catalogextensions/bestsellers_home_list" name="bestsellers_list" template="catalogextensions/home_bestsellers.phtml"}}
To see Featured products
{{block type="catalogextensions/featured_home_list" name="featured_list" template="catalogextensions/home_featured.phtml"}}
In Default attribute set >> 'Is Featured' attributes is added. You need to select “yes” value to show product as feature product
To see Mostviewed products
{{block type="catalogextensions/mostviewed_home_list" name="mostviewed_list" template="catalogextensions/home_mostviewed.phtml"}}
To see Newproduct products
{{block type="catalogextensions/newproduct_home_list" name="newproduct_list" template="catalogextensions/home_newproduct.phtml"}}
To see catalog Sale products
{{block type="catalogextensions/promotional_home_list" name="promotional_list" template="catalogextensions/home_promotional.phtml"}}
For showing the products in promotional rule, One catalog rule needs to be setup.
To see RecentlyOrdered products
{{block type="catalogextensions/lastordered_home_list" name="lastordered_home_list" template="catalogextensions/home_lastordered.phtml"}}
To see All products without any category filter
href=" echo $this->getUrl('catalogextensions/index/allproduct');" for All Products link
Also DONT FORGET TO MENTION Special price in product and enable is featured> yes
Upvotes: 0
Reputation: 2373
write :
app/code/local/Mage/Catalog/Block/Product/Special.php
<?php
class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List
{
function get_prod_count()
{
//unset any saved limits
Mage::getSingleton('catalog/session')->unsLimitPage();
return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 9;
}// get_prod_count
function get_cur_page()
{
return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1;
}// get_cur_page
/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
**/
protected function _getProductCollection()
{
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
$dateTomorrow = date('m/d/y', $tomorrow);
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$collection = $this->_addProductAttributesAndPrices($collection)
->addStoreFilter()
->addAttributeToSort('entity_id', 'desc') //<b>THIS WILL SHOW THE LATEST PRODUCTS FIRST</b>
->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(0 => array('date' => true, 'from' => $dateTomorrow), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')
->setPageSize($this->get_prod_count())
->setCurPage($this->get_cur_page());
$this->setProductCollection($collection);
return $collection;
}// _getProductCollection
}// Mage_Catalog_Block_Product_New
?>
In the CMS Page----> HOME PAGE (admin panel), click Design tab then in the Page layout -->Layout update xml put this code..
<reference name="content">
<block type="catalog/product_special" name="product_special" template="catalog/product/list.phtml">
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<action method="setDefaultDirection"><dir>desc</dir></action>
<action method="setDefaultOrder"><field>entity_id</field></action>
<block type="page/html_pager" name="product_list_toolbar_pager" />
</block>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>
Hope this helps u :P
Upvotes: 2
Reputation: 2105
You should also retrieve the 'special_price' atrribute from the set, it is easy, just adding this code:
->addAttributeToSelect(array('name', 'price', 'small_image', 'status','special_price'), 'inner')
Upvotes: 1
Reputation: 1068
It depends on how you want to serve the products. If all of your sale products are already in a sale category you could do the following, within the Layout Update XML
field of your category (see the Design
tab):
<reference name="content">
<block type="catalog/product_list" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>[your_category_id]</category_id></action>
</block>
</reference>
Though if you want to retrieve all sale products from all categories, you need to create a new block type. A great example for this is the Mage_Catalog_Block_Product_New
block type. This block is used to retrieve all new products from your store. You will almost need an exact copy of the block, only the way how the product collection is loaded in _beforeToHtml()
differs.
The collection you want to load with in the _beforeToHtml()
is then:
$collection = Mage::getResourceModel('catalog/product_collection');
$dateToday = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
$dateTomorrow = date('m/d/y', $tomorrow);
$collection
->addAttributeToFilter('special_price', array('gt' => 0))
->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $dateToday))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $dateTomorrow),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');
This retrieves all products with special price greater than zero and that special date to/from match the current date.
Upvotes: 0