开发者

How to include pagination in Magento special price page?

I want to use the special price feature of Magento and display all products with special price in a CMS page. It's working, but only 9 products will display even if I assigned a special price to 10 products. Then I thought about pagination. Now I tried those suggested methods I found Googling but they didn't work (maybe I missed something). That's why I want to ask for direction on where to begin. This is the code I used for the special price.

<?php if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
  <div class="widget widget-new-products">
<div class="widget-title">
    <h2><?php echo $this->__('Special Product') ?></h2>
</div>
<div class="widget-products">

<?php $_columnCount = $this->getColumnCount(); ?>
    <?php $i=0; foreach ($_products->getItems() as $_product): ?>
    <?php if ($i++%$_columnCount==0): ?>
    <ul class="products-grid">
    <?php endif ?>
        <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
                <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image') ?>" width="195px" height="195px" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
                <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>

                <!-- ###### BRANDS EG. BY CHIC ON A MISSION ###### -->
                <div class="product-brand"><?php echo $this->htmlEscape($_product->getextraline()) ?></div>
                <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?> 
                <?php echo $this->getPriceHtml($_product, true, '-widget-new-grid') ?>

            <div class="actions">
                <?php if($_product->isSaleable()): ?>
                    <!-- <button type="button" title="<?php /* echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_prod开发者_如何学JAVAuct) ?>')"><span><span><?php echo $this->__('Add to Cart')*/ ?></span></span></button>-->
                <?php else: ?>
                    <!--<p class="availability out-of-stock"><span><?php // echo $this->__('Out of stock') ?></span></p>-->
                    <div class="out-of-stock-special"><img src="<?php echo $this->getSkinUrl('images/donna/soldout-overon.png') ?>" alt="uitverkocht" width="50px" /></div>
                <?php endif; ?>

            </div>
            </li>
    <?php if ($i%$_columnCount==0 || $i==count($_products)): ?>
    </ul>
    <?php endif ?>
    <?php endforeach; ?>

</div>

Then I placed this code in the CMS content.

{{block type="catalog/product_special" template="catalog/product/special.phtml"}}

I tried using this code. <?php echo $this->getToolbarHtml() ?>, but it wont work. I also tried this one. <?php echo $this->getToolbarBlock()->setTemplate('catalog/product/list/ctoolbar.phtml')->toHtml(); ?>.

I also tried the layout updates in the CMS design.

<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
   <block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
<update handle="page_three_column" />

It didn't work either. Hopefully someone will guide me in this. :)


You can try this solution...

1) create your block to display the special products this way:

class Yournamespace_Mycatalog_Product_List_Specials extends Mage_Catalog_Block_Product_List{

  protected function _getProductCollection(){
    // your code here to retrieve special priced products
  }
}

2) then use an updated version of template file catalog/product/list.phtml. It should include the toolbar (let's say mycatalog/product/list/specials.phtml)

3) Update your cms block definition:

{{block type="mycatalog/product_list_specials" template="mycatalog/product/list/specials.phtml" }}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜