답변:
이 시도:
echo $_product->getResource()->getAttribute('car_options')->getFrontend()->getValue($_product);
var_dump($_product->getData('car_options');하고 출력을 확인합니다. 쉼표로 구분 된 문자열이어야합니다. 그렇지 않으면 타사 모듈이 방해한다고 상상할 수 있습니다.
$_product->getData('car_options')반환 NULL, 그것은 제품 컬렉션에 추가하지 의미합니다. 이 속성에 액세스하려는 위치에 대한 자세한 정보가 필요합니다.
$ objectManager = \ Magento \ Framework \ App \ ObjectManager :: getInstance (); $ product = $ objectManager-> get ( '마 젠토 \ 카탈로그 \ 모델 \ 제품')->로드 ($ product_id); $ attributevalues = $ product-> getResource ()-> getAttributeRawValue ($ product_id, 'my_custom_attribute_code', $ storeid);
작동합니다. 도움이 되길 바랍니다 ..
다음 코드
$ _attribute_code = 'car_options';
$ car_options_csv = 마법사 :: getResourceModel ( 'catalog / product')-> getAttributeRawValue ($ productId, $ _attribute_code, $ storeId); // 반환 : 123,124
$ car_options = explode ( ',', $ car_options_csv);
$ attributeId = 마법사 :: getResourceModel ( 'eav / entity_attribute')-> getIdByCode ( 'catalog_product', $ _ attribute_code);
$ attribute = 마법사 :: getModel ( 'catalog / resource_eav_attribute')-> load ($ attributeId);
$ attributeOptions = $ attribute-> getSource ()-> getAllOptions ();
$ res = '';
foreach ($ attributeOptions as $ a)
{
$ l = $ a [ 'label'];
$ m = $ a [ '값'];
if (strlen (trim ($ l))> 0 && in_array ($ m, $ car_options))
{
$ res. = trim ($ l). ',';
}
}
echo substr ($ res, 0, -2) ;;