Magento:在前端显示禁用的产品


Magento: Display disabled products on frontend

我想在前端显示禁用的产品。但是我该怎么做呢??

虽然我不希望它们出现在目录或搜索中,但我确实希望它们在通过直接url访问时显示"产品已禁用"。

目前目录/产品中的view.phtml没有触发并给出404页面。

我该怎么做。

仅针对类别中的禁用产品尝试此项

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

启用状态=1,禁用状态=2

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

与其禁用产品,不如将其从类别中删除,使其缺货,使其仅在目录中可见,并添加一个名为"is_discontined"(或类似的属性)的新yes/no属性。然后,在产品视图页面中检查该属性的值。如果是1,则显示您的消息Product is disabled。我以前就是这样做的,而且效果很好。