如何在 Magento 前端隐藏简单的产品?

How to hide simple products in Magento front end?

我正在以编程方式在 magento 中插入一些产品,我只想在前端显示可配置的产品(就像 magento 本身),当用户 selects "View Details" 在详细信息页面中他可以 select 属性到 select 关联的简单产品。(我不想在前端显示关联的产品) 但是现在前端的产品列表中既有可配置的产品,也有简单的产品。为什么会这样?

在简单产品的 General 选项卡中,将 Visibility 设置为 Not Visible Individually。这将从前端隐藏它们,但保持启用它们以用于可配置产品。

如果这就是您创建产品的方式,也可以通过编程方式完成:

$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)

// from Mage_Catalog_Model_Product_Visibility:
// const VISIBILITY_NOT_VISIBLE    = 1;
// const VISIBILITY_IN_CATALOG     = 2;
// const VISIBILITY_IN_SEARCH      = 3;
// const VISIBILITY_BOTH           = 4;

// remember to call $product->save() at some point

谢谢朋友们!我找到了。我将可见性设置为 Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH,现在可以了

如果你想在前台隐藏简单的产品,你也可以在后台隐藏,无需编写任何代码。

转到目录 -> 管理产品,在类型下拉列表中,过滤 "simple product"。过滤 select 所有产品和 select "Update Attributes" 后,来自 Mass action。从那里将可见性更改为 "Not Visible Individually",这将应用于所有简单产品。