Created
February 23, 2015 08:30
-
-
Save devjosh12/f3c184385c610396463e to your computer and use it in GitHub Desktop.
subcatgeory in left side
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Magento | |
* | |
* NOTICE OF LICENSE | |
* | |
* This source file is subject to the Academic Free License (AFL 3.0) | |
* that is bundled with this package in the file LICENSE_AFL.txt. | |
* It is also available through the world-wide-web at this URL: | |
* http://opensource.org/licenses/afl-3.0.php | |
* If you did not receive a copy of the license and are unable to | |
* obtain it through the world-wide-web, please send an email | |
* to [email protected] so we can send you a copy immediately. | |
* | |
* DISCLAIMER | |
* | |
* Do not edit or add to this file if you wish to upgrade Magento to newer | |
* versions in the future. If you wish to customize Magento for your | |
* needs please refer to http://www.magentocommerce.com for more information. | |
* | |
* @category design | |
* @package base_default | |
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) | |
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | |
*/ | |
?> | |
<?php | |
/** | |
* Category layered navigation | |
* | |
* @see Mage_Catalog_Block_Layer_View | |
*/ | |
?> | |
<div class="block block-layered-nav"> | |
<div class="block-title"> | |
<strong><span><?php echo $this->__('Shop By') ?></span></strong> | |
</div> | |
<?php $currenturl = $this->getUrl(); | |
$searchurl = $currenturl . 'catalogsearch/result/'; | |
//echo $searchurl; | |
//echo $_GET['q']; | |
?> | |
<?php $reqstprodchildids = Mage::registry('req_prod_ids'); ?> | |
<ul> | |
<?php | |
$obj = new Mage_Catalog_Block_Navigation(); | |
$storeCategories = $obj->getStoreCategories(); | |
Mage::registry('current_category') ? $currentCategoryId = Mage::registry('current_category')->getId() : $currentCategoryId=''; | |
foreach ($storeCategories as $_category): | |
?> | |
<li> | |
<strong><?php echo $_category->getName(); ?></strong> | |
<?php $categoryChildren = $_category->getChildren(); ?> | |
<?php if($categoryChildren->count()) : ?> | |
<ul> | |
<?php foreach($categoryChildren as $_categoryChild) : ?> | |
<?php $_categoryChildModel = Mage::getModel('catalog/category')->load($_categoryChild->getId());?> | |
<?php $categoryGrandchildren=$_categoryChild->getChildren(); ?> | |
<li> | |
<?php | |
$_productCollection = Mage::getResourceModel('catalog/product_collection'); | |
$_productCollection->addCategoryFilter($_categoryChildModel); | |
$_productCollection->addAttributeToFilter('entity_id',array('entity_id','in'=>$reqstprodchildids)); | |
$prodcatarray = array(); | |
foreach($_productCollection as $showcat) { | |
$prodid = $showcat->getId(); | |
array_push($prodcatarray,$prodid); | |
} | |
?> | |
<?php | |
if(count($prodcatarray) > 0) { | |
$currentCategoryId===$_categoryChild->getId() ? $bold="style=\"font-weight:bold\"" : $bold=''; | |
echo ' ' . '<a class="grand" rel='.json_encode($prodcatarray).' id="'.$_categoryChild->getId().'" href="'.$searchurl.'?q='.$_GET['q'].'&catid='.$_categoryChild->getId().'"' . $bold . '>' . $_categoryChild->getName() . '(' . count($prodcatarray) . ')</a>'; | |
} | |
?> | |
</li> | |
<?php if($categoryGrandchildren->count()) : ?> | |
<?php foreach($categoryGrandchildren as $_categoryGrandchild) : ?> | |
<?php $_categoryGrandchildModel = Mage::getModel('catalog/category')->load($_categoryGrandchild->getId());?> | |
<li> | |
<?php | |
$_productCollectionchild = Mage::getResourceModel('catalog/product_collection'); | |
$_productCollectionchild->addCategoryFilter($_categoryGrandchildModel); | |
$_productCollectionchild->addAttributeToFilter('entity_id',array('in'=>$reqstprodchildids)); | |
$childprodcatarray = array(); | |
foreach($_productCollectionchild as $showchildcat) { | |
$childprodid = $showchildcat->getId(); | |
array_push($childprodcatarray,$childprodid); | |
} | |
//print_r($childprodcatarray); | |
?> | |
<?php | |
if(count($childprodcatarray) > 0) { | |
$currentCategoryId===$_categoryChild->getId() ? $bold="style=\"font-weight:bold\"" : $bold=''; | |
echo '  ' . '<a class="grand" rel='.json_encode($childprodcatarray).' id="'.$_categoryGrandchild->getId().'" href="'.$searchurl.'?q='.$_GET['q'].'&catid='.$_categoryGrandchild->getId().'"' . $bold . '>' . $_categoryGrandchild->getName() . '(' . count($childprodcatarray). ')</a>'; | |
} | |
?> | |
</li> | |
<?php endforeach; ?> | |
<?php endif; ?> | |
<?php endforeach; ?> | |
</ul> | |
<?php endif; ?> | |
</li> | |
<?php endforeach ?> | |
</ul> | |
</div> | |
<script> | |
/*jQuery(document).ready(function() { | |
jQuery('.grand').click(function(){ | |
var catid = jQuery(this).attr('id'); | |
var relval = jQuery(this).attr('rel'); | |
var collect = jQuery.parseJSON(relval); | |
var newredirect = window.location.href + '&cat='+catid; | |
jQuery.ajax({ | |
type:'post', | |
url:'http://192.168.1.140/~djoshi/magento17/index.php/mycustomers/index/Showsearch', | |
data: 'cat_id='+catid+'&pro_collect='+collect, | |
beforeSend:function(){ | |
//location.reload(true); | |
}, | |
success:function(data){ | |
if(data){ | |
//alert(data); | |
if(newredirect) { | |
window.location.href = newredirect; | |
jQuery('.category-products').html(data); | |
} | |
} | |
} | |
}); | |
}); | |
});*/ | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment