【问题标题】:Get all attributes assigned to attribute group获取分配给属性组的所有属性
【发布时间】:2012-10-16 19:23:49
【问题描述】:

我正在为 magento 开发一个导入模块。我需要找出一个属性是否属于一个属性组。我加载了属性以及属性组。我试过了:

$attributeCollection = $attributeGroup->getAttributes();

理论上,我可以查看集合,并确定属性是否已分配给属性组。

【问题讨论】:

标签: php magento attributes


【解决方案1】:

您可以从属性中获取组 id,并在需要时加载组。

$product = Mage::getModel('catalog/product')->load(ID_HERE);
foreach($product->getAttributes() as $attribute)
{
    $groupId = $attribute->getAttributeGroupId();
}

如果你想加载组模型:

$group = Mage::getModel('eav/entity_attribute_group')->load($groupId);   

【讨论】:

  • 这对我不起作用,因为我有 groupId 并且需要知道分配给它的属性。
  • 那很简单,在 foreach 中你只需这样做: if($attribute->getAttributeGroupId() == GROUP_ID) .. 使用 SQL/Collections 等可能有更好的方法
猜你喜欢
  • 2020-06-12
  • 2018-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-09
  • 1970-01-01
  • 2012-06-09
  • 2011-12-16
相关资源
最近更新 更多