Show deactivated / disabled products in comparison

I am trying to show the product as a comparison, which is set as status = disabled through the admin panel.

By default, magento does not seem to be able to do this because disabled products do not appear on the product list page or on the product details page.

Somehow I managed to show disabled products on the product list page and product details page, overriding Mage_Catalog_Helper_Product . In this, I commented on the following code:

  // if (!$this->canShow($product)) { // return false; // } 

Now please help me find out how to show a disabled product even in comparison?

+7
php magento
source share
3 answers

After a long search and the inability to extract the solution from the main mage files, I created an attribute that performs the same actions as the status attribute. I named this attribute as Archive (Yes / No). This new attribute will justify the cancellation of the product or not.

Atlast, I am filtering the list of all my products, product information, and the homepage associated with this new Archive attribute only.

I plan to write an MVC action that will change all status products as enabled and at the same time run Archive as yes for status = disabled products. I will share this code soon.

The code

Write a dummy controller that runs the following code when 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. } } 
+4
source share

Maybe you want to check: public function isEnabled

in Magento \ application \ code \ kernel \ Mage \ Directory \ Helper \ Product \ Flat.php

+4
source share

I quickly looked at which block creates the list. A good place to run would be the following file:

app / code / core / Mage / Catalog / Block / Product / Compare / List.php

There is a getItems function that is responsible for getting elements ready for display on the front side. At the end of this function, it passes the elements through the visibility method:

 Mage::getSingleton('catalog/product_visibility') ->addVisibleInSiteFilterToCollection($this->_items); 

Im not 100% sure if deleting this final section of code will give you what you want, but at the most basic level, you can change the collection to ignore the status you set.

+4
source share

All Articles