I am quite newbie to the Magento. Currently I am doing a theme. In that I want to show all the products from featured category. For that I have done a file called featred.phtml
inside
/app/design/frontend/mytheme/default/template/catalog/product
. The code for featured.phtml
is like this
<?php $cat_id = 35; ?>
<?php $category = Mage::getModel('catalog/category')->load($cat_id);?>
<?php $collection = $category->getProductCollection()->addAttributeToSort('position');?>
<?php Mage::getModel('catalog/layer')->prepareProductCollection($collection);?>
<?php $i=0; foreach ($collection as $_product):?>
<?php if($i++%7==0): ?>
<div class="container">
<div id="da-slider" class="da-slider">
<?php endif ?>
<div class="da-slide">
<h2 class="product-name"><?php echo $this->htmlEscape($_product->getName()) ?></h2>
<p class="price"><?php echo $formattedSpecialPrice = Mage::helper('core')->currency($_product->getFinalPrice(),true,false);?></p>
<p><?php echo $_product->_data['short_description']; ?> </p> <br />
<a class="da-link" href="<?php echo $_product->getProductUrl() ?>">Shop Now</a>
<div class="da-img"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(90, 90); ?>" width="120" height="120" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></div>
<!--.da-img-->
</div><!--.da-slide-->
<?php endforeach ?>
<nav class="da-arrows">
<span class="da-arrows-prev"></span>
<span class="da-arrows-next"></span>
</nav><!--.da-arrows-->
</div><!--#da-slider-->
</div><!--.container-->
Now Here I am getting al the featured product. After that I want to show all the featured product in my header. For that I have made a block in page.xml(app/design/frontend/mytheme/default/layout)
like this
<block type="catalog/product_featured" name="product.featured" as="topSlider" translate="label">
<label>Page Slider</label>
<action method="setElementClass"><value>top-slider</value></action>
</block>
Now I called that block in header.phtml
like this
<?php echo $this->getChildHtml('topSlider'); ?>
But after all this I can't see any of the featured product in my home page or in any other pages. So can someone kindly tell me how to solve this issue? Any help and suggestions will be really appreciable. Thanks