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

low stock rss feed - modify to only show enabled products
 
tegansnyder
Member
 
Avatar
Total Posts:  48
Joined:  2008-10-23
Saint Paul, MN
 

Why does the low stock rss feed show include products that are disabled?

I only want it to show products that I have enabled on the site.

I’m found the code that displays the feed:
/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php

I tried adding a check to see if the product is enabled in the following code:

public function addNotifyItemXmlCallback($args)
    
{
        $product 
$args['product'];
        
$product->setData($args['row']);
        
$url Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit/', array('id'=>$product->getId(),'_secure' => true,'_nosecret' => true));
        
$description Mage::helper('rss')->__('%s has reached a quantity of %s.'$product->getName(),(1*$product->getQty()));
        
$rssObj $args['rssObj'];
        
//ADDED THIS--- it only outputs disabled to the /var/log/system.log
        
if ($product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED{
            Mage
::log('enabled');
        
else {
            Mage
::log('disabled');
        
}
        
        $data 
= array(
        
'title'         => $product->getName(),
        
'link'          => $url,
        
'description'   => $product->getSku() . ' - ' .$description,
        );
        
$rssObj->_addEntry($data);
    
}
}

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tegansnyder
Member
 
Avatar
Total Posts:  48
Joined:  2008-10-23
Saint Paul, MN
 

Got it working… thanks to finding a neat magento blog site by Branko Ajzele called activecodeline.com

Here is the updated function.

public function addNotifyItemXmlCallback($args)
    
{
        $product 
$args['product'];
        
$product->setData($args['row']);
        
$url Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit/', array('id'=>$product->getId(),'_secure' => true,'_nosecret' => true));
        
$description Mage::helper('rss')->__('%s has reached a quantity of %s.'$product->getName(),(1*$product->getQty()));
        
$rssObj $args['rssObj'];
        
        
$cProduct Mage::getModel('catalog/product');
        
$cProduct->load($product->getId());
        
        if (
$cProduct->getStatus() == '1'){
      
          $data 
= array(
          
'title'         => $product->getName(),
          
'link'          => $url,
          
'description'   => $product->getSku() . ' - ' $description,
          );
          
$rssObj->_addEntry($data);
          
        
}
    }
 
Magento Community Magento Community
Magento Community
Magento Community
 
meeeearcus
Member
 
Total Posts:  57
Joined:  2008-07-01
 

Thank you for replying to your own thread with a solution. Even if I’m the only one to reply so far I know you have probably helped countless others looking for the same solution. Bravo!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hagure
Jr. Member
 
Total Posts:  1
Joined:  2009-10-05
 

Just wanted to chime in and say thanks.

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