magento 获取属性集中的可配置属性

magento get Configurable attributes in attribute set

如何获取属性集中的所有可配置属性?

我正在循环所有属性集,然后我只想显示其可配置属性。

您应该能够获取属性集合并对其进行过滤(基于属性集)- 这将 return 指定集合中所有可配置的属性。

$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeSetFilter($attributeSetId)
->addFieldToFilter("is_configurable", array("eq", "1"))
->getItems();

我假设您所说的可配置属性实际上是指可用于创建可配置产品的属性。 Douglas Radburn 的回答是正确的方法,它只缺少两个过滤器。正如您在上图中所看到的,使用属性创建可配置产品有三个条件。以图像的信息为参考,我们可以构建以下集合。

$attributes = Mage::getResourceModel("catalog/product_attribute_collection")
->setAttributeSetFilter($attributeSetId)
->addFieldToFilter("frontend_input", "select")
->addFieldToFilter("is_configurable", "1")
->addFieldToFilter("is_global", "1");

这会起作用:

$objAttributes = Mage::getResourceModel('catalog/product_attribute_collection')
->addFieldToFilter("is_configurable", array("1"))
->getItems();