且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento的:从属性获得的属性设置无产品

更新时间:2023-11-30 09:48:16

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