Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Sale page
 
neilbradley
Member
 
Avatar
Total Posts:  43
Joined:  2010-01-07
 

Hi there,

I’m trying to create a ‘Sale’ page. So far I have created the file \app\code\local\Mage\Catalog\Block\Product\Special.php with the code;

class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List 
{
    
/**
     * Retrieve loaded category collection
     *
     * @return Mage_Eav_Model_Entity_Collection_Abstract
     */
    
protected function _getProductCollection()
    
{     
        $todayDate 
date('m/d/y');
        
$tomorrow mktime(000date('m'), date('d')+1date('y'));
        
$tomorrowDate date('m/d/y'$tomorrow);

        
$collection Mage::getResourceModel('catalogsearch/advanced_collection')
            ->
addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
            ->
addMinimalPrice()
            ->
addStoreFilter();
        
        
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
        
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
        
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($_productCollection);

        
$collection->addAttributeToFilter('special_from_date', array('date' => true'to' => $todayDate))         
        ->
addAttributeToFilter('special_to_date', array('or'=> array(
                        
=> array('date' => true'from' => $tomorrowDate),
                        
=> array('is' => new Zend_Db_Expr('null')))
                        ), 
'left');
   
          return 
$collection;
    
}

}

I have then created a new CMS page titled Sale with this code;

{{block type='catalog/product_special' template='catalog/product/list.phtml'}}

The problem I get is that the grid of products only has 3 columns, whereas all of my other grid catalog pages have 5 columns. Additionally, this page is showing Sale items that are no longer in stock.

I wondered if anyone knows how I can get it to display 5 columns and only show saleable items?

Thanks,
Neil

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

May be this thread helps: http://www.magentocommerce.com/boards/viewthread/23060/

 
Magento Community Magento Community
Magento Community
Magento Community
 
neilbradley
Member
 
Avatar
Total Posts:  43
Joined:  2010-01-07
 

Thanks Amasty. I’m using some similar code myself, which is displaying products. It’s just displaying some that are no longer in stock. :(

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top