Magento 1.9 – Category and Product Listing on Single Page with Condition

magento-1.9

i have a dslr main category which contains 4 different subcategories. dslr is included in navigation menu with url dslr.html.

in dslr.html page i have shown subcategories list. (DSLR Category : Display mode => static block only & CMS Block => subcateogry listing and this subcategory listing block includes phtml file subcategory-listing.phtml file to display subcategories under current category.)

Now, in navigation menu i have listed brands under dslr (as dropdown) sony,panasonic etc. When i click on sony under dslr i want to show all dslr of sony brand. and i have url of this like this mystie.com/dslr.html?manufacturer=11. And this url doesn't show me products under dslr assigned to sony as the dslr category has display mode=>static block.

It shows as correctly if i made dslr category Display mode=>products but when someone clicks on dslr link i need to show subcategories listings.

So how can i manage two different displays under same link and with manufacturer id being passed on url ?

Best Answer

You can modified in category view file as per your custom requirement

copy file

app/design/frontend/base/default/template/catalog/category/view.phtml

to your theme

app/design/frontend/your_package/your_theme/template/catalog/category/view.phtml

and change code something like

<?php
    $_helper    = $this->helper('catalog/output');
    $_category  = $this->getCurrentCategory();
    $_imgHtml   = '';
    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></p>';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
    }
?>
<div class="page-title category-title">
    <?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        <a href="<?php echo $this->getRssLink() ?>" class="link-rss"><?php echo $this->__('Subscribe to RSS Feed') ?></a>
    <?php endif; ?>
    <h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
</div>

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

<?php if($_imgUrl): ?>
    <?php echo $_imgHtml ?>
<?php endif; ?>

<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
    <div class="category-description std">
        <?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
    </div>
    <?php endif; ?>

<?php $manufacturer = Mage::app()->getRequest()->getParam('manufacturer'); ?>

<?php if($this->isContentMode() && !$manufacturer): ?>
    <?php echo $this->getCmsBlockHtml() ?>

<?php elseif($this->isMixedMode()): ?>
    <?php echo $this->getCmsBlockHtml() ?>
    <?php echo $this->getProductListHtml() ?>

<?php else: ?>
    <?php echo $this->getProductListHtml() ?>
<?php endif; ?>

Also make sure you don't have mix mode for any other category or you need to put condition for that also.

Related Topic