To Get the Distinct Product from Two Categories

<?php

$_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();
function getCategoryCount($cid,$bid){
$productss = Mage::getModel('catalog/product')->getCollection()
    ->joinField('category_id_1', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
    ->joinField('category_id_2', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
    ->addAttributeToFilter('category_id_1', array('eq' => $cid))
    ->addAttributeToFilter('category_id_2', array('eq' => $bid));    

echo count($productss);
}
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
?>




<div class="block_listing">
    <div class="block block-layered-nav">
        <div class="block-content">
            <dl id="narrow-by-list">
                    <dt class="last odd">Category</dt>
                        <dd class="last odd">
                            <ol>
                                <li><a href="<?php echo $currentUrl; ?>?cat=5&brandcat=<?php echo $curent_cat_id; ?>">Men</a>(<?php getCategoryCount(5,$curent_cat_id); ?>)</li>
                                <li><a href="<?php echo $currentUrl; ?>?cat=6&brandcat=<?php echo $curent_cat_id; ?>">Women</a>(<?php getCategoryCount('6',$curent_cat_id); ?>)</li>
                                <li><a href="<?php echo $currentUrl; ?>?cat=99&brandcat=<?php echo $curent_cat_id; ?>">Kids</a>(<?php getCategoryCount('99',$curent_cat_id); ?>)</li>
                                <li><a href="<?php echo $currentUrl; ?>?cat=25&brandcat=<?php echo $curent_cat_id; ?>">Shoes</a>(<?php getCategoryCount('25',$curent_cat_id); ?>)</li>
                                <li><a href="<?php echo $currentUrl; ?>?cat=100&brandcat=<?php echo $curent_cat_id; ?>">Accessories</a>(<?php getCategoryCount('100',$curent_cat_id); ?>)</li>
                                <li><a href="<?php echo $currentUrl; ?>?cat=102&brandcat=<?php echo $curent_cat_id; ?>">Sale</a>(<?php getCategoryCount('102',$curent_cat_id); ?>)</li>
                                <li><a href="<?php echo $currentUrl; ?>?cat=103&brandcat=<?php echo $curent_cat_id; ?>">Outlet</a>(<?php getCategoryCount('103',$curent_cat_id); ?>)</li>
 
                            </ol>
                        </dd>
             </dl>
         </div>
    </div>
</div>

Comments

Popular Posts

Magmi Single and Multiple Category Importer