<?php  ?>
<li><a href="<? echo $this->getUrl();?>designer"><span>Designer</span></a>
<ul class="designer">
<li class="first designer_section"><h4>Men's Designer</h4>
<span class="designer_section">
<?php
$product = Mage::getModel('catalog/product');
// load a product collection filtered by desginersex
$productCollection = $product->getCollection()
//->distinct(true)
//->addAttributeToSelect('designername')
->addAttributeToSelect('*')
->addAttributeToFilter('designersex', 128)
->load();
// process the collection
$i = 0;
foreach ($productCollection as $prod) { 
//print_r($prod->getdesigner());
$designer_name[$i] = $prod->getAttributeText('designer');
$designer_id[$i] = $prod->getdesigner();
$i++;
}
$count = $i -1;
if($count >30)
$count = 30;
$temp = '';
$k = 0;
for($i = 0; $i < $count; $i++)
{
for($j = $i + 1; $j < $count; $j++){ 
if($designer_name[$i] == $designer_name[$j]){
$designer_name[$j] = '';
//$count--;
}
}
}
for($i = 0; $i < $count; $i++)
if($designer_name[$i]!= ''){
echo '<span><a href="'.$this->getUrl().'designer_list?gender=male&designer='.$designer_id[$i].'">'.$designer_name[$i].'</a></span>';
}
?>
</span>
</li> 
<li class="first designer_section"><h4>Women's Designer</h4> 
<span class="designer_section">
<?php
$product = Mage::getModel('catalog/product');
// load a product collection filtered by desginersex
$productCollection = $product->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('designersex', 127)
->load();
$i = 0;
foreach ($productCollection as $prod) { 
$designer_name[$i] = $prod->getAttributeText('designer');
$designer_id[$i] = $prod->getdesigner();
$i++;
}
$count = $i;
if($count >30)
$count = 30;
$temp = '';
$k = 0;
for($i = 0; $i < $count; $i++)
{
for($j = $i + 1; $j < $count; $j++){ 
if($designer_name[$i] == $designer_name[$j]){
$designer_name[$j] = '';
//$count--;
}
}
}
for($i = 0; $i < $count; $i++)
if($designer_name[$i]!= '')
echo '<span><a href="'.$this->getUrl().'designer_list?gender=female&designer='.$designer_id[$i].'">'.$designer_name[$i].'</a></span>';
?>
</span>     
</li>
<a style="float:left; color:#fff; font-size:10px; padding-left:20px;" href="<? echo $this->getUrl();?>designer"> View All</a>
</ul>
</li>
<?php  ?>
Monday, July 26, 2010
What should we do if we need to create menu navigation with product attributes??
Subscribe to:
Post Comments (Atom)
 
 
 
No comments:
Post a Comment