1

I am sure others have encountered this problem before and I am wondering if anyone knows of a solution.

I would like my product to be searchable in the advanced search by a range of sizes.

For example, one parameter would be:

Width: From (dropdown menu)' (dropdown menu)" x To (dropdown menu)' (dropdown menu)"

Height: From (dropdown menu)' (dropdown menu)" x To (dropdown menu)' (dropdown menu)"

In the backend, I would have four attributes:

  1. Width-Feet
  2. Width-Inches
  3. Height-Feet
  4. Height-Inches

Or, two attributes:

  1. Width - Inches
  2. Height - Inches

And I could convert the length in inches to a foot and inches format.

Any help would be greatly appreciated!

UPDATE:

I am still kind of lost on how to do something like this (add another parameter for the advanced search). I was assuming that many people would encounter this issue but I have not been able to find any tutorial(s) that I have helped.

2 Answers 2

2

First of all I recommend to create two different attributes, one for width and one for height. But you can also store both in one field and separate it by a specified character. But it's easier to filter and sort if you have different fields.

When saving the attribute convert the feet to inches or vice versa, but I would only store feet or inches, not both. You could do this in the backend model of your attribute.

The official manual of how to create a custom attribute (or two) is a good entrance point for that: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module

Do you want to have the same type of input in the frontend for the layered navigation? Usually the layered navigation is filtering for one exact value, but you can extend that behavior in the apply() method of Mage_Catalog_Model_Layer_Filter_Attribute.

0
1

2 Attributes, Store them in millimeters or even just inches. The math is pretty easy:

$inches = ceil($mm/25.4);
$feet = floor(($inches/12));

As for the custom module, all you really need to do is make a custom module that modifies the search result collection with something like:

Mage::getModel('catalog/product')
            ->getCollection()
            ->addFieldToFilter('attribute_one',array('from'=>'10','to'=>'20'))
            ->addFieldToFilter('attribute_two',array('from'=>'10','to'=>'20'))
    );

Hope this helps.

5
  • I think that the OP wants to add this filter capability from the Advanced Search view. How would you add this in?
    – philwinkle
    Commented Apr 30, 2013 at 22:16
  • @B00MER - I first went through the tutorial on setting up a "Hello World" controller action and now am going through the Varien Data Collections tutorial. I got through the "Collection of Things" section well, but I am having trouble on the "Model Collections" section. For example, for the public function testAction() method, which Mage Class would I have to extend to access the 'catalog/product' model? Currently, I have only the following class after following the controller action tutorial: class Kokorugs_Helloworld_IndexController extends Mage_Core_Controller_Front_Action. Thanks for help! Commented May 1, 2013 at 14:32
  • I know it might be a silly question, but I feel (hope) like I am close to some kind of Magento revelation! Commented May 1, 2013 at 14:34
  • In other worlds, what do I have to do to be able to access Magento's Models and/or Blocks <i>inside my "Hello World" controller action</i>? Commented May 1, 2013 at 14:36
  • It sounds as though you may need to read up on MVC's and how it works. You may benefit from reading the entire guide here: magentocommerce.com/knowledge-base/entry/…
    – B00MER
    Commented May 3, 2013 at 4:25

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.