1

Besides 'Category', 'Material', 'Brand', 'Color', 'By price range', 'Color Group', and 'Price', I'd like to add the filter 'Shipped by'

This is what I have in my view:
app/design/frontend/{my_theme}/template/catalog/layer/view.phtml

Code:

                <dl id="narrow-by-list">
                <?php $_filters = $this->getFilters() ?>
                <?php $allowedfilter = Array('Category', 'Material', 'Brand', 'Color', 'By price range', 'Color Group', 'Price'); ?>
                <?php foreach ($_filters as $_filter): ?>
                    <?php if ($_filter->getItemsCount() && in_array($_filter->getName(), $allowedfilter)): ?>
                        <dt>
                            <span><?php echo str_replace(' Group', '', $this->__($_filter->getName())) ?></span>
                        </dt>
                        <dd>
                            <?php echo $_filter->getHtml() ?>
                        </dd>
                    <?php endif; ?>
                <?php endforeach; ?>
            </dl>

Now, this is what I have in my filter:
app/design/frontend/{my_theme}/template/catalog/layer/filter.phtml

Code:

<ol>
<?php
$brandsort = Array();
if (preg_match('/Brand/i', $this->getName())) {
    $attribute = Mage::getModel('eav/entity_attribute')->load('brand', 'attribute_code');
    $option_col = Mage::getResourceModel('eav/entity_attribute_option_collection')->setAttributeFilter($attribute->getId())
        ->setOrder('sort_order');
    foreach ($option_col as $theoption) {
        if ($theoption['sort_order'] < 1) $theoption['sort_order'] = 999;
        $brandsort[$theoption['option_id']] = $theoption['sort_order'];
    }
}

$items = $this->getItems();

$branditems = Array();
if (preg_match('/Brand/i', $this->getName())) {
    foreach ($items as $key => $item) {
        $items[$key]['sort_order'] = $brandsort[$item['value']];
    }
    function cmp($a, $b) {
        return $a['sort_order'] - $b['sort_order'];
    }

    usort($items, "cmp");
}

?>
<?php foreach ($items as $_item): ?>
    <li>
        <a href="<?php echo $this->urlEscape($_item->getUrl()) ?>">
            <?php if ($_item->getCount() > 0): ?>
                <?php if (file_exists('skin/frontend/{my_theme}/images/colors/' . strtolower(str_replace(' ', '_', $_item->getLabel())) . '.jpg') && preg_match('/Color/i', $this->getAttributeModel()->getFrontendLabel())):
                    echo '<img style="border:1px solid #CCCCCC;margin-bottom:3px !important;" src="/skin/frontend/{my_theme}/images/colors/' . strtolower(str_replace(' ', '_', $_item->getLabel())) . '.jpg" alt="' . $_item->getLabel() . '" />';
                endif; ?>
                <?php echo $_item->getLabel() ?>
            <?php endif; ?>
        </a>
        <?php if ($this->shouldDisplayProductCount()): ?>
            (<?php echo $_item->getCount() ?>)
        <?php endif; ?>
    </li>
<?php endforeach ?>

I found this code that I think it does what I want, but I don't know how to integrate it to my existing code:

$items->joinField('manages_stock','cataloginventory/stock_item','use_config_manage_stock','product_id=entity_id','cataloginventory_stock_item.use_config_manage_stock=1 or cataloginventory_stock_item.manage_stock=1');

What I want is to filter products given the values of use_config_manage_stock and manage_stock i.e. products that are shipped from the stores of shipped by the manufacturer.

It doesn't have to be this way, I'm just bringing what I have so far.

Any help will be appreciated.

1 Answer 1

1

You can create your module according to this module

https://github.com/Marko-M/Inchoo_Sale

Hope this will be helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.