Display only enabled products in magento my wishlist

耗尽温柔 提交于 2019-12-23 21:49:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!