We created custom module and we saved list of product Brands
& Models
in backend. In below image, Apple, sony, samsung
are brands & iphone4, iphone4s...etc
are models.
Brands
Models
We want to create dropdown options for both Brands & Models in frontend. Once we select particular brand from 1st drop-down box, then only associated models should display in 2nd Drop-down box.
Company/Brand/Block/Frontend/View.php
class Company_Brand_Block_Frontend_View extends Mage_Catalog_Block_Product_Abstract
{
protected function _prepareLayout()
{
$this->getLayout()->createBlock('catalog/breadcrumbs');
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$product = $this->getProduct();
$title = $product->getMetaTitle();
if ($title) {
$headBlock->setTitle($title);
}
$keyword = $product->getMetaKeyword();
$currentCategory = Mage::registry('current_category');
if ($keyword) {
$headBlock->setKeywords($keyword);
} elseif ($currentCategory) {
$headBlock->setKeywords($product->getName());
}
$description = $product->getMetaDescription();
if ($description) {
$headBlock->setDescription( ($description) );
} else {
$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
}
if ($this->helper('catalog/product')->canUseCanonicalTag()) {
$params = array('_ignore_category' => true);
$headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params));
}
}
return parent::_prepareLayout();
}
public function getProduct()
{
$collection = Mage::getModel('catalog/category')->load(310)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('custom_phone_case', 1);
$products=$collection->getFirstItem();
$product = Mage::getModel('catalog/product')->load($products->getId());
$p=Mage::registry('product');
if ($p=='') {Mage::register('product', $product);}
return $product;
}
I will give 50 bounty if it works for me.
Best Answer
Create a select box for
Brands
like :Now create an array for
Models
(withbrand_id
), like :Now add a
jQuery
function :