2012-02-01 2 views
0

안녕 Magento 사이트의 foreach 루프에 대한 활성 상태를 얻으려고합니다.Magento 사용자 정의 링크가 활성 설정 됨

ksort($catArr); 


foreach($catArr as $postion=>$catId){ 
$_category = Mage::getModel("catalog/category")->load($catId); 
?> 
<?php 
if($_category->getIsActive()) 
{ 
$caturl = $_category->getURL(); 
$catname = $_category->getName(); 
?> 

<?php if($_category->getdata('left_menu')): ?> 

<a href="<?php echo "$caturl" ?>" > <li class="leftnav" ><div class="nav-name"> 
<?php echo $catname ?></div></li></a> 
<?php endif ?> 
<?php 
} 
?> 
<?php 
} 
?> 
</ul> 
</div> 
<?php endif ?> 

답변

0

당신이 카테고리가 활성화 여부를 확인하려면 희망 : 나는 모든 것을 시도했지만, 그냥 작업을 실 거예요 .. 여기 내 코드입니다. 그렇다면 is_active가 콜렉션에있는 경우 다음 코드 행이 도움이 될 수 있습니다.

$_category->getData('is_active') 

당신은 사용 컬렉션에 추가하려면

addFieldToSelect('is_Active') 
+0

나는 젠토 1.6.1 실제로이 부분에 대한 활성 상태 얻기 위해 노력하고 실행하고 있습니다 : 그렇다면 " >

  • 을 링크가 클릭되었습니다 Andy106

    +0

    where is the code please? – Andy106

    +0

    Find my new answer. Hope thats what you need. – Haijerome

    0
    /*to get current category ID*/ 
    $category_nav_obj = new Mage_Catalog_Block_Navigation(); 
    $current_category= $category_nav_obj->getCurrentCategory(); 
    $current_category_id = $current_category->getId(); 
    
    /*Then loop as per your code*/ 
    
    foreach(....): 
    
    if($category->getId()==$current_category_id): 
        /*do whatever you want to highlight the category*/ 
    endforeach; 
    
    +0

    나는 치명적 오류가 발생합니다 :/home 오류가 아닌 객체에서 getId() 멤버 함수를 호출하십시오. – Andy106

    관련 문제