2010-07-18 9 views
2

Magento shop에 여러 가지 이진 속성이있는 속성 세트를 설정했습니다.Magento : 제품이없는 속성 세트에서 속성 가져 오기

풀다운의 경우 내부 이름과 라벨을 포함하여이 속성 집합 내의 모든 속성 목록이 필요합니다. 이 풀다운이 반드시 제품을 선택하지 않은 장소에 나타나야하므로 "제품의 속성 가져 오기"의 일반적인 경로를 수행 할 수 없습니다.

내 세트의 모든 속성 목록을 가져 오는 방법은 무엇입니까?

답변

5

OK, 나는 당신이 속성의 전체 집합이 아니라 개인을 원하는 놓친 것을 깨달았다. 이 시도 :

원래 포인트를 누락
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; 

죄송합니다,이 도움이되기를 바랍니다 :

$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(); 

당신은 다음과 같은 뭔가 반환되는 배열을 반복해야합니다!

$entityTypeId = Mage::getModel('eav/entity') 
                ->setType('catalog_product') 
                ->getTypeId(); 
$attributeSetName   = 'Default'; //Edit with your required Attribute Set Name 
$attributeSetId     = Mage::getModel('eav/entity_attribute_set') 
                    ->getCollection() 
                    ->setEntityTypeFilter($entityTypeId) 
                    ->addFieldToFilter('attribute_set_name', $attributeSetName) 
                    ->getFirstItem() 
                    ->getAttributeSetId(); 
$attributes = Mage::getModel('catalog/product_attribute_api')->items($attributeSetId); 
foreach($attributes as $_attribute){ 
    print_r($_attribute); 
} 

건배! :

건배, JD

+0

훨씬 더 좋습니다. 귀하의 코드를 사용할 때 속성 목록은 얻을 수 있지만 내 사용자 정의 목록은 가져 오지 않습니다. 왜 그런지 모르겠지만 "-> setEntityTypeFilter"를 4에서 10으로 전환하여 가져 왔습니다. 그냥 무작위로 시도하여 거기에 도착했습니다. :) 어쨌든. – Sorcy

+0

문제 없습니다. db의 eav_entity_type 테이블을보고 엔터티의 ID를 찾을 수 있어야한다. 10 = sales/quote_payment, 적어도 Mage v1.4.1처럼 보입니다. 그것이 당신을 위해 일해 준 것을 기쁘게 생각합니다. :) JD –

+0

@FabianBlechschmidt –

1

이 스 니펫을 시도하면 다중 선택 속성을 제외하고는 필요로 할 것입니다. 이 도움이

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product','attribute_name'); 
    foreach($attribute->getSource()->getAllOptions(true,true) as $option){ 
     $attributeArray[$option['value']] = $option['label']; 
    } 
    return $attributeArray; 

희망, JD

+0

아니, 그냥 빈 배열을 반환합니다. : – Sorcy

5

속성 세트의 모든 속성을 얻기 위해, 당신은을 사용할 수 있습니다