Magento的:从属性获得的属性设置无产品 [英] Magento: getting attributes from an attribute set without a product

查看:128
本文介绍了Magento的:从属性获得的属性设置无产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置有哪几种二进制属性在我的Magento店设置的属性。

I have set an attribute set in my Magento shop which has several binary attributes.

有关下拉,我需要这一个属性集内的所有属性的列表,包括其内部名称和标签。由于该下拉应该出现在未必有一个产品选择,我不能走得到一个产品的属性的通常路线的地方。

For a pulldown I need a list of ALL the attributes inside this one attribute set, including their internal name and their label. Since this pulldown should appear in places that not necessarily have a product selected I can't go the usual route of "getting the attributes of a product".

我如何去获得我的组内的所有属性的列表呢?

How do I go about of getting a list of all the attributes inside my set?

推荐答案

OK,我意识到,我错过了你希望整个属性集,不仅是个人的。试试这个:

OK, I realised that I missed that you want the whole set of attributes, not just an individual one. Try this:

$productEntityType = Mage::getModel('eav/entity_type')->loadByCode(Mage_Catalog_Model_Product::ENTITY);

$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection');
$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
    ->setEntityTypeFilter($productEntityType->getId())  //4 = product entities
    ->addSetInfo()
    ->getData();

您将需要再通过与类似返回的数组遍历:

You'll then need to iterate through the array that is returned with something like:

foreach($attributesInfo as $attribute):
    $attribute = Mage::getModel('eav/entity_attribute')->load($attribute['attribute_id']);
    echo 'label = '.$attribute->getFrontendLabel().'<br/>';
    echo 'code = '.$attribute->getAttributeCode().'<br/><br/>';
endforeach;

抱歉错过了原点,希望这有助于!

Sorry for missing the original point, hope this helps!

干杯,
JD

Cheers, JD

这篇关于Magento的:从属性获得的属性设置无产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆