Magento: Display disabled products on frontend [closed]

前提是你 提交于 2019-12-12 04:06:29

问题


I want to show disabled products on front end. But how can I do it??

Although I don't want them to be appeared in catalog or search, but I do want them to be appeared when accessed by direct url saying "Product is Disabled".

Right now view.phtml in catalog/product is not triggering and giving a 404 page.

How can I do this.


回答1:


Try this one for only disabled products within a category

$products = Mage::getModel('catalog/category')->load($category_id)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(
    'status',
    array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
);

Status Enabled = 1 and Status Disabled = 2

$products = Mage::getModel('catalog/category')->load($category_id)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter(
    'status',
    array('eq' => '2')
);



回答2:


Instead of disabling a product, just remove it from the categories, set it out of stock, set it visible only in catalog, and add a new yes/no attribute called 'is_discontinued' (or something like that). Then, in the product view page check the value of that attribute. If it's 1 the display your message Product is disabled. This is how I used to do it and it worked just fine.



来源:https://stackoverflow.com/questions/18281442/magento-display-disabled-products-on-frontend

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