I have a Magento website selling magazine subscriptions, about a 1000 different titels. What I would like is to create a very simple dropdown menu prefilled with all products on the frontpage. Very much like this, only I cannot seem to replace the ‘manufactures’ with ‘name’ (the product name).
An example can be found here with a different website selling magazine subscriptions as well (right top, left to the search field).
Can someone present we with some code to create such a dropdownlist?
Looking at the other website you linked to, the drop down HTML looks like this, with a small snippet of JavaScript inside
onselectattribute to navigate to the URL of the selected product:The JavaScript navigates by setting
window.location.hrefto a new URL, and it gets this URL fromthis.valuewhich is the value of the selected<option>.To render a drop down like this in Magento you first have to get all products using Mike Bywaters’ code (filtered by visible and whatnot). Then you loop through all the products and you
echothe<option>tag for each product with the correct value:If
$productis the result of a call toMage::getModel(...)then a call to$product->getUrlPath()should return the path of the product, as documented here.