"속성 값"(option_id)을 갖는 속성 "옵션 레이블 / 속성 텍스트"를 얻는 방법은 무엇입니까?


18

옵션 모음 (드롭 다운 / multiselect) 인 속성이 있다고 가정합니다.

주어진 제품의 속성 값을 검색 할 수 있습니다.

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

이제 숫자 값인 option_id 속성이 있습니다 ...

... 내 속성 값에 대한 프론트 엔드 속성 레이블을로드하는 가장 좋은 방법은 무엇입니까? (전체 제품을로드하지 않고)

솔루션 감사 Marius :

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);

2
왜이 질문이 정확한 저자와 혼란스러운 사용자에 의해 여러 번 주어 졌는가. 정답없이이 질문들처럼 중복으로 표시 할 수 있습니까? 이 magento.stackexchange.com/questions/3003의 저자에 의해 주어진 질문에는 정답은 없지만, 왜 upvotes (주어진 자신의 대답)! 이 하나의 magento.stackexchange.com/questions/976 도 동일합니다. 어쩌면 내 요청은 옳지 않지만 질문 하나, 저자 하나, 대답은 없습니다. 사이트의 품질을 유지하십시오. 감사.
— mageUz


1
Magento CE 1.9 및 EE 1.14 이하에서는 getAttributeText('value')속성의 getAllOptions()메소드가 중첩 배열로 배열 된 옵션을 <optgroup>드롭 다운 으로 표시하는 옵션을 반환 하면 제대로 작동하지 않습니다 .
— Tyler V.

답변:


49

코드 외에도 다음을 입력하십시오.

$product = Mage::getModel('catalog/product')
                ->setStoreId($store_id)
                ->setBrand($brand_value); // not loading the product - just creating a simple instance
$brandLabel = $product->getAttributeText('brand');

9
$attribute = Mage::getModel('catalog/resource_eav_attribute')
            ->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'manufacturer');
$label     = $attribute->getFrontendLabel();

1
"프런트 엔드 속성 레이블"이 혼동되었으므로 질문을 수정하십시오. "속성 레이블"이 아니라 "옵션 레이블"또는 "속성 텍스트"
— mageUz
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.