问题
When users login and click on my wishlist link it display the products. But it display the disabled products also. I want to display only the enabled products in wishlist. Can any one suggest me how to make changes in code so that it will display only enabled products in my wishlist area.
回答1:
You probably have to extend this class Mage_Wishlist_Model_Wishlist
and override the method getItemCollection
by adding a filter by status. Something like this (untested, just added the last method call):
$this->_itemCollection = Mage::getResourceModel('wishlist/item_collection')
->setStoreId($this->getStore()->getId())
->addWishlistFilter($this)
->addAttributeToFilter(
'status',
array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
);
Note that this would exclude the disabled products every time you load the collection of Wishlist items, not only from the wishlist page, but also from potentially any place where you are displaying it, which I think is what you want.
来源:https://stackoverflow.com/questions/27920610/display-only-enabled-products-in-magento-my-wishlist