开发者

How do I send parameters to advanced search in Magento?

I have the following search form in Magen开发者_运维知识库to:

<form action="catalogsearch/advanced/result/" method="get" id="form-validate"> 

<input name="name" type="text" id="textfield" value="" /> 

<select name="platform" id="select"> 
      <option value='6'>XBox</option>
      <option value='5'>XBox 360</option>
</select>

<input type="submit" name="button" id="button" value="Search" /> 

</form>

Please note the “platform” field is a product attribute. While "name" field is product name.

No matter what I search, the results page always say “No items were found using the following search criteria”

I can see that two parameters are being passed:

result/?name=Logitech&platform;=5

Even if I change this to following, it doesn’t work:

result/?name=Logitech&platform;=XBox

Changing this to doesn’t work either:

result/?name=Logitech

The product is there in database I have checked. What am I doing wrong?

Thanks


This is quick a cut/paste from a code I used for a client whose attribute was a dropdown-type attribute.

Your attribute code must be "platform" for this to work.

<?
 $product = Mage::getModel('catalog/product');
 $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
         ->setEntityTypeFilter($product->getResource()->getTypeId())
         ->addFieldToFilter('attribute_code', 'platform');
 $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
 $_platforms = $attribute->getSource()->getAllOptions(false);
 ?>
<select onchange="location.href='<?php echo $this->getUrl('catalogsearch/advanced/result') . '?platform[]='; ?>'+this.value;">
   <option selected><?php echo $this->__('Search by platform') ?></option>
    <?php foreach($_platforms as $_platform) : ?>
   <option value="<?php echo $_platform['value']; ?>"><?php echo $_platform['label']; ?></option>
    <?php endforeach; ?>
  </select>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜