0
我對Magento非常陌生。目前我正在做一個主題。我希望展示來自特色類別的所有產品。爲此,我在 /app/design/frontend/mytheme/default/template/catalog/product
之內完成了一個名爲featred.phtml
的文件。爲featured.phtml
的代碼是這樣的magento顯示標題中的特色產品
<?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-->
現在在這裏我得到了人特色產品。之後,我想在我的標題中顯示所有特色產品。對於我在page.xml(app/design/frontend/mytheme/default/layout)
做了塊這樣的
<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>
現在我給那塊header.phtml
這樣
<?php echo $this->getChildHtml('topSlider'); ?>
但畢竟這我看不到任何特色產品的我主頁或任何其他頁面。那麼有人可以告訴我如何解決這個問題?任何幫助和建議都將非常可觀。由於