After searching for a long time and failing to extract a solution from mage core files, I created an attribute which does the same as status
attribute. I named that attribute as Archive
(Yes/No). This new attribute will justify whether a product is discontinued or not.
Atlast, I filter all my product listing, product details and home page related to this new attribute Archive
only.
I am planning to write a MVC action, which will change all the products status
as enabled
and at the same time triggering the Archive
as yes for the status = disabled
products. I will share the code here soon.
Code:
Write a dummy controller which runs the following code when the url is called:
public function updateproductsAction() {
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter('type_id', array('eq' => 'configurable'))
->addAttributeToFilter('entity_id', array('gt' => 0)); // This line should be removed to affect all the configurable products. (to avoid execution time-out)
echo 'Total are ' . count($collectionConfigurable) . '<br/>';
$i = 1;
foreach($collectionConfigurable as $p) {
$product = Mage::getModel('catalog/product')->load($p->getId());
$product->save();
echo $i++ . ') The product Id with ' . $p->getId() . " is done...." . "<br/>"; // if the execution time-out occurs, note down the last product id and change the value above in addAttributeToFilter. so the execution runs from the last stopped product.
}
}