Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $param = '';
- if(isset($_GET['cat'])) {
- $curCatId = $_GET['cat'];
- $curCat = Mage::getModel('catalog/category')->load($curCatId);
- $param = "&cat=$curCatId";
- } else {
- $curCat = Mage::getSingleton('catalog/layer')->getCurrentCategory();
- }
- $subCatIds = $curCat->getAllChildren(true);
- $_filters = $this->getActiveFilters();
- ?>
- <?php if(!empty($_filters)): ?>
- <div class="state">
- <p class="block-subtitle"><?php echo $this->__('Currently Shopping by:') ?></p>
- <dl>
- <?php foreach ($_filters as $_filter): ?>
- <dd>
- <?php if(get_class($_filter->getFilter()) == 'Mage_Catalog_Model_Layer_Filter_Attribute') :?>
- <?php
- $attributeModel = $_filter->getFilter()->getAttributeModel();
- $attrOptions = $attributeModel->getSource()->getAllOptions(); //array of options
- $catModel= Mage::getModel('catalog/category');
- $filterColor = $this->stripTags($_filter->getLabel());
- $colors = '';
- foreach($subCatIds as $catId) {
- $catModel->load($catId);
- $collection = $catModel->getProductCollection();
- $collection->addAttributeToSelect('apparel_color_value')
- ->getSelect()->group('apparel_color_value');
- foreach($collection as $product) {
- if ($product->isSaleable()) {
- $colors .= $product['apparel_color_value'].',';
- }
- }
- }
- ?>
- <ol id="option-list-<?php echo $attributeModel->getAttributeId() ?>">
- <?php foreach($attrOptions as $attr): ?>
- <?php if($attr['value']): ?>
- <?php if($attr["label"] != $filterColor): ?>
- <?php if(strpos($colors, $attr["label"].',') !== false) : ?>
- <li><a href="<?php echo $this->getUrl('').$curCat->getUrlPath() ?>?apparel_color=<?php echo $attr["value"]?><?php echo $param ?>" ><?php echo $attr["label"]; ?></a></li>
- <?php endif; ?>
- <?php else:?>
- <li class="current"> <?php echo $filterColor; ?></li>
- <?php endif;?>
- <?php endif; ?>
- <?php endforeach; ?>
- </ol>
- <script type="text/javascript">decorateList('option-list-<?php echo $attributeModel->getAttributeId() ?>', 'none-recursive')</script>
- <?php else:?>
- <ol>
- <li>
- <a href="<?php echo $_filter->getRemoveUrl() ?>" title="<?php echo $this->__('Remove This Item') ?>" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a>
- <span class="label"><?php echo $this->__($_filter->getName()) ?>:</span> <?php echo $_filter->getLabel() ?>
- </li>
- </ol>
- <?php endif; ?>
- </dd>
- <?php endforeach; ?>
- </dl>
- <a class="all" style="float:right;" href="<?php echo $this->getClearUrl()?>">All</a>
- </div>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement