0

is there any way to show disabled products in category rss feed also?

Magento 1.6.1.0

1 Answer 1

1

[EDIT] After some investigations I found out that is not possible. Not in a decent period of time at least.
The table catalog_category_product_index is joined with the product collection in order to get the products associated to that category. And in that index table the disabled products do not appear.

So in order to get your disabled products also you will need to rewrite the whole _toHtml method in the Mage_Rss_Block_Catalog_Category block and avoid using addCategoryFilter.

[Original Post]
I don't know why would you need that. If you show disabled products in RSS then the link in the feed will point to a 404 page.
But anyway...here is how you can do it.
You need to rewrite the Mage_Rss_Block_Catalog_Category::_toHtml method.
Here is what you need to change.

$productCollection = Mage::getModel('catalog/product')->getCollection(); 

needs to become

$productCollection = Mage::getResourceModel('catalog/product_collection'); 

because if you have the flat catalog enabled, the disabled products are not indexed in the flat tables so you won't be able to access them. This way you use directly the EAV tables.

Then you need to replace

$layer->prepareProductCollection($productCollection); 

with

$productCollection ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes()) //add some attributes to select ->addMinimalPrice() //add all kind of prices to select ->addFinalPrice() ->addTaxPercents() ->addUrlRewrite($currentCategory->getId()); Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection); //filter only visible products. 

This is needed because the prepareProductCollection method filters out the disabled products. The code I suggested is basically the same thing as in prepareProductCollection but I removed the status filter.

4
  • Hi Marius, thank you for your quick response! I copied the PHP-File to local and changed the file as you said. Sadly there are still only the enabled products. Commented Sep 18, 2014 at 8:22
  • Ok. I will try to come up with something better. But keep in mind that only 50 products are shown in the RSS feed sorted by the last update time. Maybe your last 50 updated products are all enabled. Try to disable one. any product, because then it should be moved to the top of the list. Commented Sep 18, 2014 at 8:24
  • Yes, I saw the comment in the method. But there are only 3 products in the tested category. 2 enabled, 1 disabled and the RSS feed only shows 2 enabled products. Commented Sep 18, 2014 at 8:29
  • @Sebastian. See my update. Bad news. Commented Sep 18, 2014 at 8:49

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.