简体   繁体   中英

Magento - How to Add Custom Filter to Layered Navigation

I have 3 text attributes I want to create a custom products filter based on them. The store is selling tires and we want to be able to filter by tire's size (which is those 3 attributes together)

I already implemented the functionality and it works great BUT its core PHP hard coded in layer/view.phtml (and another external file), now I need to take the same code but make it a custom filter integrated in Magento framework.

I tried following this tutorial - http://www.techytalk.info/create-custom-layered-navigation-filter-magento but no lack.

so far I created a new module but it doesn't seem to show up in the frontend (I do see it the advanced section in the backend).

I think the main problem right now is the config.xml file:

<config>
<global>
    <models>
        <Companyname_Modulename>
            <class>Companyname_Modulename_Model</class>
        </Companyname_Modulename>
    </models>

    <blocks>
        <Companyname_Modulename>
            <class>Companyname_Modulename_Block</class>
        </Companyname_Modulename>
    </blocks>

    <helpers>
        <Companyname_Modulename>
            <class>Companyname_Modulename_Helper</class>
        </Companyname_Modulename>
    </helpers>

</global>

Any insights?

I think you're missing the <frontend> options in config.xml.

<config>
  <frontend>
    <layout>
      <updates>
        <{namespace}_{module}>
          <file>{module}.xml</file>
        </{namespace}_{module}>
      </updates>
    </layout>
    <router>
      <{module}>
        <use>standard</use>
        <args>
          <module>{Namespace}_{Module}</module>
          <frontName>{module}</frontName>
        </args>
      </{module}>
    </router>
  </frontend>
</config>

Do you have the module declaration in the config node of your config.xml file?

<config>
    <modules>
        <Companyname_Modulename>
            <version>x.x.x</version>
        </Companyname_Modulename>
    </modules>
...
</config>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM