1

I am customizing mobile theme for my magento store. I need to implement a search functionality in the front page of my mobile theme. Layered navigation is not there in the default iphone mobile theme. So I had put some piece of code for displaying attributes in a select box and created a search button there. I was successful in publishing the back end attributes there in a select box but can't able to make a search box functionality with that. When observing magento's layered navigation, i found that layered navigation search is working like creating a dynamic URL with selected attribute value id. So i decided to create search just like layered navigation does. But for creating dynamic url it seems to be i need a piece of code for fetching the selected attribute option id. I tried many codes for getting that option id, but was not successful. Any one please gave me a hand.

spider
  • 320
  • 1
  • 2
  • 10

1 Answers1

1

Try using the advanced search functionality instead. I think that would be much easier. Just a suggestion.

Shatir
  • 617
  • 1
  • 5
  • 18
  • but i need to publish search fields in home page itself. – spider May 08 '13 at 13:26
  • for which attributes do you want to provide a search box functionality – Shatir May 08 '13 at 14:06
  • actually i had put some custom attributes(not custom options) in the back end. I was successful in publishing those attributes in a select box.Actually my plan was to make a search box which is behaving just like select box layered navigation. For that i had observed the layered navigation in magento. They are making a dynamic URL in the value field of each select box options, by getting the **attribute option value id**. So i decided to follow the same concept. But i can't able to fetch attribute option value id, is there any piece of code for fetching this? – spider May 09 '13 at 04:29
  • This is the used code :- `$attributeCode = 'tyrewidth'; $attributeModel = Mage::getSingleton('eav/config') ->getAttribute('catalog_product', $attributeCode); $select = Mage::getSingleton('core/resource') ->getConnection('default_read')->select() ->from($attributeModel->getBackendTable(), 'value') ->where('attribute_id=?', $attributeModel->getId()) ->distinct(); // read used values from the db $usedAttributeValues = Mage::getSingleton('core/resource') ->getConnection('default_read') ->fetchCol($select);` – spider May 09 '13 at 04:31
  • `// map used id's to the value labels using the source model if ($attributeModel->usesSource()) { $usedAttributeValues = $attributeModel->getSource()->getOptionText( implode(',', $usedAttributeValues) ); }` – spider May 09 '13 at 04:33
  • For implementing a select box layered navigation, you'd have to populate the select box for an attribute with all possible options that it has. Have you done this? – Shatir May 09 '13 at 07:15
  • yeah that is done, i did populated the select box. but search functionality on select box change is what missing. – spider May 09 '13 at 09:24
  • Read this link : http://www.webdesign-gm.co.uk/news/web-design/magento-web-design/layered-navigation-on-home-page-or-any-cms-page-magento.php You'll have to integrate your dropdown with it – Shatir May 09 '13 at 11:27
  • Even though that was not the thing i was looking, that link really helped me to change my path, it worked mate, i had created a layered navigation with that. Cheers!!! – spider May 21 '13 at 12:11