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

问题描述:

我想在前端显示禁用的产品。但我怎么能这样做?Magento:在前端显示禁用的产品

尽管我不希望它们出现在目录或搜索中,但我确实希望它们在通过直接url访问时显示为“Product is Disabled”。

现在目录/产品中的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') 
); 
+0

我的意思是产品页面。这是通过404错误。不在类别列表中。您在列出产品时是正确的,但我现在确定如何在产品页面中显示它。 – TheGodWings

+0

然后删除类别过滤器,只是得到产品集合和'addAttributeToFilter'获得残疾人产品 –

+0

我真的很抱歉误会,我没有得到产品清单,我展示了像http://domain.com/这样的单一产品。 product.html – TheGodWings

而不是禁用的一款产品,只是从类别中删除它,将其设置为缺货,仅在目录中将其设置为可见,并添加一个名为'is_discontinued'的新的yes/no属性(或类似的东西)。然后,在产品视图页面中检查该属性的值。如果是1,则显示消息Product is disabled。这是我以前的做法,它工作得很好。