php 畅销产品畅销书

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 畅销产品畅销书相关的知识,希望对你有一定的参考价值。

http://inchoo.net/ecommerce/magento/bestseller-products-in-magento/

//{{block type="catalog/product_list" name="bestsellers.product.list" showproducts="6" template="additional/bestsellers-list.phtml"}}
<?php
    $_products = Mage::getResourceModel('reports/product_collection')
        ->addAttributeToSelect('*')
        ->addOrderedQty()
        ->setOrder('ordered_qty','desc');
        
    $cnt = 0;
    
    if($this->showproducts)
        $showproducts = $this->showproducts;
    else
        $showproducts = 6;
?>    
<?php if($_products && count($_products) > 0): ?>
    <div class="box best-selling">
        <h2><?php echo $this->__('Popular Products') ?></h2>
        <ul class="products-grid cm-products-grid">
            <?php foreach($_products as $item): $cnt++; ?>
                <?php $_product = Mage::getModel('catalog/product')->load($item->getId()); ?>
                <li>
                    <div class="box-info">
                        <a href="<?php echo $item->getProductUrl(); ?>">
                            <img class="product-img" src="<?php echo $this->helper('catalog/image')->init($item, 'small_image')->resize(180); ?>" width="180" height="180" alt="<?php echo $this->stripTags($this->getImageLabel($item, 'small_image'), null, true) ?>" />
                        </a>
                        <div class="product-description">
                            <h2 class="product-name"><a href="<?php echo $item->getProductUrl(); ?>"><?php echo $item->getName(); ?></a></h2>
                        </div>
                        <?php echo $this->getPriceHtml($_product, true) ?>
                        <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($_product) ?>')"><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>
                            <?php endif; ?>
                            <ul class="add-to-links">
                                <?php if ($this->helper('wishlist')->isAllow()) : ?>
                                    <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('+ Add to Wishlist') ?></a></li>
                                <?php endif; ?>
                                <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                                    <li><a href="<?php echo $_compareUrl ?>" class="link-wishlist"><?php echo $this->__('+ Add to Compare') ?></a></li>
                                <?php endif; ?>
                            </ul>
                        </div>
                    </div>
                </li>
            <?php if($cnt == $showproducts) break; endforeach; ?>
        </ul>
        <script type="text/javascript">decorateGeneric($$('ul.products-grid li'), ['odd','even','first','last'])</script>
    </div>
<?php else: ?>
    <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php endif; ?>

以上是关于php 畅销产品畅销书的主要内容,如果未能解决你的问题,请参考以下文章

计算或汇总 MySQL 中最畅销的产品

如何在Prestashop中展示畅销产品?

Nerd的畅销产品

Oracle SQL中如何选择五款畅销产品?

显示最畅销的产品对

php wc畅销书循环