2012-11-26 5 views
4

"제품 목록에 사용 된"속성이 "예"로 선택되어 있지만 $ attribute-> getIsVisibleOnFront()와 같은 기능을 찾지 못했습니다.Magento. 속성이 제품 목록에 사용되는지 여부를 어떻게 알 수 있습니까?

실제로 어떻게해야하는지 모르겠습니다. 속성의 '프런트 엔드 속성'에서 옵션 값 (빠른 검색 사용, 고급 검색에 사용 ...)

내 코드는 다음과 같은 뭔가를해야만이다

<?php $attributes = $_product->getAttributes();    
    foreach ($attributes as $attribute) { 
     if ($attribute->getIsUsedInProductListing()) { 
         echo $attribute->getStoreLabel(); 
        } 
      } 
    ?> 

getIsUsedInProductListing()가 존재하지 않는다; -)

Th anks ...

답변

5

네, 이것은 매우 쉽게 할 수 있습니다.

$product = Mage::getModel('catalog/product')->load($productId); // Or, use your product 
$attributes = $product->getTypeInstance(true)->getSetAttributes($product); 

foreach ($attributes as $attribute){ 
    var_dump($attribute); // You will be able to see all of the attribute settings here. 

    if ($attribute->getUsedInProductListing()) { 
      // Do cool things here. 
    } 

    if ($attribute->getIsHtmlAllowedOnFront()) { 
      // Do cool things here. 
    } 

    if ($attribute->getIsVisibleInAdvancedSearch()) { 
      // Do cool things here. 
    } 

    if ($attribute->getUsedForSortBy()) { 
      // Do cool things here. 
    } 
} 
+0

오 !!! 고맙습니다 !!! 약간의 수정 만 (최소한 나를 위해) : $ 속성 = $ product-> getTypeInstance (true) -> getSetAttributes ($ product); – Ruanova

+0

도와 드리겠습니다! –

관련 문제