<?php $cats = Mage::getModel('catalog/category')->load(2)->getChildrenCategories(); ?>
<ul>
<?php foreach($cats as $category): ?>
<li><a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?> </a>
<?php $category_id = $category->getId() ?>
(<?php echo $count = Mage::getModel('catalog/category')->load($category_id)->getProductCount(); ?>)
<?php $catagory_model = Mage::getModel('catalog/category')->load($category_id); //where $category_id is the id of the category ?>
<?php
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addCategoryFilter($catagory_model); //category filter
$collection->addAttributeToFilter('status',1); //only enabled product
$collection->addAttributeToSelect(array('name','url','small_image','price','special_price','description','short_description')); //add product attribute to be fetched
//$collection->getSelect()->order('rand()'); //uncomment to get products in random order
$collection->addStoreFilter();
if($count > 0)
{ ?>
<table>
<tr>
<?php
$z=1;
foreach ($collection as $_product): ?>
<td>
<table>
<tr>
<td><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product_img_link"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(200); ?>" width="200" height="200" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a></td>
</tr>
<tr>
<td><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $_product->getName(); ?></a></td>
</tr>
<tr>
<tr>
<td><?php $_pci = $this->htmlEscape($_product->getPrice());
echo number_format($_pci,2); ?>
</td>
</tr>
<td><?php $_splprice = $_product->getSpecialPrice(); //get Product's Special price
if(!$_splprice==''){
echo number_format($_splprice,2); } ?></td>
</tr>
<tr>
<td><?php echo $_product->getShortDescription(); //get product's short description ?></td>
</tr>
<tr>
<td><?php echo $_product->getDescription(); //get Product's Long Description ?></td>
</tr>
</tr></table>
<?php /*?><?php echo $_product->getId(); ?><?php */?>
<?php //echo Mage::getBaseUrl(); ?>
<?php if($_product->isSaleable()): ?>
<?php /*?><p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p><?php */?>
<p><button onclick="setLocation('<?php echo Mage::getBaseUrl(); ?>checkout/cart/add?product=<?php echo $_product->getId(); ?>&qty;=1')" class="button btn-cart"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<?php /*?><?php //echo $_product->getFinalPrice(); ?>
<?php //echo $_product->getSpecialPrice(); ?>
<?php //echo $_product->getPrice(); ?>
<?php //echo $this->htmlEscape($_product->getName()); ?>
<?php echo $this->htmlEscape($_product->getPrice()); ?>
<?php echo $this->htmlEscape($_product->getSpecialPrice()); ?>
<?php
//echo $_product->getName(); // get Product's name
echo $_product->getShortDescription(); //get product's short description
echo $_product->getDescription(); //get Product's Long Description
//echo $_product->getPrice(); //get Product's Regular Price
echo $_product->getSpecialPrice(); //get Product's Special price
//echo $_product->getProductUrl(); //get Product's Url
//echo $_product->getImageUrl(); //get Product's image Url
?><?php */?>
</td>
<?php if($z%3==0){?>
</tr>
<tr>
<?php } $z++; ?>
<?php endforeach; ?>
</tr>
</table>
<?php } else { ?>
<table>
<tr><td>
<?php echo 'No products Assigned in this Category'; ?>
</td></tr></table>
<?php } ?>
</li>
<?php endforeach; ?>
</ul>
<?php /*?>****************************************
<?php
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
?>
<?php foreach ($manufacturers as $manufacturer)
{ ?>
<?php echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['value'];
<?php echo Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=$manufacturer['label'];
<?php } ?>
****************************************
<?php
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer') // This can be changed to any attribute code
->load(false);
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
foreach ($manufacturers as $manufacturer)
{
echo $manufacturer;
}
?>
****************************************
<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
{
$attributeArray[$option['value']] = $option['label'];
}
foreach($attributeArray as $key=>$val)
{
echo $val;
} ?>
****************************************
<?php
$attribute = Mage::getModel('eav/entity_attribute')
->loadByCode('catalog_product', 'manufacturer');
$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setAttributeFilter($attribute->getData('attribute_id'))
->setStoreFilter(0, false);
$preparedManufacturers = array();
foreach($valuesCollection as $value) {
$preparedManufacturers[$value->getOptionId()] = $value->getValue();
}
if (count($preparedManufacturers)) {
echo "<h2>Manufacturers</h2><ul>";
foreach($preparedManufacturers as $optionId => $value)
{
echo "<li>" . $value . " - (" . $optionId . ")</li>";
}
echo "</ul>";
}
?>
****************************************
<?php
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
{
$attributeArray[$option['value']] = $option['label'];
}
$attributes = Mage::getModel('catalogsearch/advanced')->getAttributes();
$attributeArray=array();
foreach($attributes as $a)
{
if($a->getAttributeCode() == 'manufacturer')
{ ?>
<table><tr>
<?php foreach($a->getSource()->getAllOptions(false) as $option)
{ ?>
<td><?php echo $attributeArray[$option['value']] = $option['label']; ?></td>
<?php } ?>
</tr></table>
<?php }
}
?>
<?php */?>
<?php /*?><?php foreach ($manufacturers as $manufacturer): ?>
<a href="<?php echo $manufacturer->getUrl() ?>"><?php echo $this->htmlEscape($manufacturer->getManufacturer()) ?></a><br />
<?php endforeach ?>
</div>
<?php if ($this->getTotal() > count($manufacturers)): ?>
<div class="actions"><a href="<?php echo Mage::helper('aitmanufacturers')->getManufacturersUrl() ?>" title="<?php echo $this->__('Full list of Brands')?>"><?php echo $this->__('More...')?></a></div>
<?php endif ?> <?php */?>