我们创建了自定义模块,并保存了产品列表Brands
&后端Models
。在下面的图片中,Apple, sony, samsung
是品牌& iphone4, iphone4s...etc
是模特。
品牌
模型
我们希望为品牌和广告创建下拉选项一旦我们从第一个下拉框中选择特定品牌,只有关联的模型应该在第二个下拉框中显示,前端的模型。作为here
公司/品牌/块/前/ 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;
}
如果它对我有用,我会给予50赏金。