欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

magento 首頁添加隨機產品 add a Random Featur

系統 2289 0

want to show products from a specific category on your home page you can do this simply with

    {{block type="catalog/product_list" category_id="12" template="catalog/product/list.phtml"}}
  
?

on your home page which works fine.. however, if you want these products to be randomly selected you hit problems.

?

The obvious thing to try is

    {{block type="catalog/product_list_random" category_id="12" template="catalog/product/list.phtml"}}
  
?

however, this displays random products from EVERY category!!

?

The reason for this is that the file random.php does not work as advertised so we need to create a new version that does. We do not want to break upgrade compatibility so create the following directory structure.

in app/code/local create Mage/Catalog/Block/Product/List

eg mkdir -p Mage/Catalog/Block/Product/List

?

In your new List directory create the following file called Random.php

    <?php
class Mage_Catalog_Block_Product_List_Random extends Mage_Catalog_Block_Product_List
{
    protected function _getProductCollection()
    {
        if (is_null($this->_productCollection)) {
            $categoryID = $this->getCategoryId();
            if($categoryID)
            {
              $category = new Mage_Catalog_Model_Category();
              $category->load($categoryID); // this is category id
              $collection = $category->getProductCollection();
            } else
            {
              $collection = Mage::getResourceModel('catalog/product_collection');
            }
            Mage::getModel('catalog/layer')->prepareProductCollection($collection);
            $collection->getSelect()->order('rand()');
            $collection->addStoreFilter();
            $numProducts = $this->getNumProducts() ? $this->getNumProducts() : 3;
            $collection->setPage(1, $numProducts)->load();
 
            $this->_productCollection = $collection;
        }
        return $this->_productCollection;
    }
}
  
?

To call this on your home page open your Home page in CMS > Static Pages and in Content add

    {{block type="catalog/product_list_random" category_id="YOUR_CATEGORY_ID" template="catalog/product/list.phtml" column_count="4" num_products="12"}}
  
?

Create a new hidden category and add the products you wish to randomly select from. Find the category ID of this category and enter this number in the above place marker.

?

You will find that although you are seeing the Category display tool bar (drid view / list view / show.. etc) it has no effect on the layout. the default layout is 3 x 3 grid which is where column_count=”4″ comes into play. Alter this to meet your themes needs. Same goes for num_products=”12″.

?

And that is that.

?

Don’t want to be looking at the grid.. hide it. (evil hack alert)

?

Add

    <style type="text/css">
.toolbar {display:none;}
</style>
  
?

at the top of your Content area on the homepage CMS. this will hide the tool bar for just the homepage.
References:


Thanks to mac75a here : http://www.magentocommerce.com/boards/viewthread/72319/ and andytm here: http://www.magentocommerce.com/boards/viewthread/72319/

?

?

結合以下內容:

- Create a category to contain the featured products. Call it e.g. “ Featured ” or “ Home Pag e”. Set “ Is Active ” to No . That way, it won’t display in the catalog menu. - After saving the category, please note what ID it gets. You can see it in the last part of the URL . If the URL ends with catalog_category/edit/id/8/ , the ID is 8 . On later version, the ID is next to the category name:

?

-

?

Add products for the home page to the new category. - Edit the Home Page ( CMS → Manage Pages → Home Page ) and add the following content, where 8 should be replaced by your category ID:

    {{block type="catalog/product_list" category_id="8" template="catalog/product/list.phtml"}}
  
?

If your product/list.html references $this→getColumnCount() you can vary the column count (e.g. 4 columns) from the default (3) displayed by using:

    {{block type="catalog/product_list" column_count="4" category_id="8" template="catalog/product/list.phtml"}}
  
?

Although displaying more than 3 columns in your template would likely require additional CSS /layout changes as well.

?

If you want a view that is different from the category lists, you can copy and modify list.phtml and change the path above. Following steps is an example.

?

Add Bestsellers to Home Page using the best-selling box of Blue Theme

In Blue Theme, there is a sample HTML code in the content box ( Admin → CMS → Manage Pages → Home Page ) that displays a list of Best Selling Products. You can easily modify list.phtml to reuse the skin of the best-selling box. Adding featured products to Home Page is a matter of clicking to select the required products in the category ( Admin → CMS → Manage Categories → Category Products tab ) as outlined in the above method and there is no need to mess with the HTML code in the CMS .

?

1. Copy the following code to your preferred text editor

    <?php $_productCollection=$this->getLoadedProductCollection() ?>
<?php if(!$_productCollection->count()): ?>
<div class="note-msg">
    <?php echo $this->__('There are no products matching the selection.') ?>
</div>
<?php else: ?>
<div class="box best-selling">
<?php $_collectionSize = $_productCollection->count() ?>
<table border="0" cellspacing="0">
<tbody>
    <?php $i=0; foreach ($_productCollection as $_product): ?>
        <?php if($i++%2==0): ?>
        <tr>
        <?php endif; ?>
            <td>
                <a href="<?php echo $_product->getProductUrl() ?>" >
                <img class="product-img" src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(95, 95); ?>" width="95" height="95" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
                </a>
                <div class="product-description">
                <p><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
                <?php echo $this->getPriceHtml($_product, true) ?>
                <?php if($_product->getRatingSummary()): ?>
                    <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                <?php endif; ?>
                <?php echo nl2br($_product->getShortDescription()) ?>
                <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><small><?php echo $this->__('Learn More') ?></small></a>
            </td>
        <?php if($i%2==0 || $i==$_collectionSize): ?>
        </tr>
        <?php endif; ?>
    <?php endforeach ?>
    <script type="text/javascript">decorateGeneric($$('tr'), ['last', 'odd', 'even']);</script>
</tbody>
</table>
</div>
<?php endif; //$_productCollection->count() ?>
  
?

2. Name it homelist.phtml and save it in location a pp/design/frontend/default/blue/template/catalog/product , create the folders where necessary

?

3. Edit the Home Page ( CMS → Manage Pages → Home Page ) and add the following content, where 19 should be replaced by your category ID:

    <h3>Best Selling Products</h3>
{{block type="catalog/product_list" category_id="19" template="catalog/product/homelist.phtml"}} 
  
?

If you follow this Wiki, you’ll notice that the breadcrumbs in the Product Page include the inactive category in the middle ( Home/Inactive/Product ) and if you click on the category, you’ll be served with a 404. Following steps show you how to hide the inactive category.

  1. Rename your category by adding a prefix ‘0’(Admin → Catalog → Manage Categories → select the inactive category → Name), if your category name is Bestsellers, then rename it 0Bestsellers. This only works if names of other active categories do not start with ‘0’.
  2. Edit breadcrumbs.phtml located in app/design/frontend/default/default/template/page/html by adding this <?php if($_crumbInfo[’label’][0]!=’0’): ?> to line 31 and this <?php endif; ?> at line 44. (The line numbers are based on version 1.2.0.2) The complete code:
    <?php if($crumbs && is_array($crumbs)): ?>
<h4 class="no-display"><?php echo $this->__("You're currently on:") ?></h4>
<ul class="breadcrumbs">
    <?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
      <?php if($_crumbInfo['label'][0]!='0'): ?>  
        <li class="<?php echo $_crumbName ?>">
        <?php if($_crumbInfo['link']): ?>
            <a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $_crumbInfo['title'] ?>"><?php echo $_crumbInfo['label'] ?></a>
        <?php elseif($_crumbInfo['last']): ?>
            <strong><?php echo $_crumbInfo['label'] ?></strong>
        <?php else: ?>
            <?php echo $_crumbInfo['label'] ?>
        <?php endif; ?>
        </li>
        <?php if(!$_crumbInfo['last']): ?>
        <li> / </li>
        <?php endif; ?>
      <?php endif; ?> 
    <?php endforeach; ?>
</ul>
<?php endif; ?>
  
?
  1. Save the file to the Blue Theme directory here: app/design/frontend/default/blue/template/page/html (If you are using other theme, then save it in the corresponding directory.)

Please note: In order to make this work for more than one block of products with different category IDs on the same page, you need to add the following code at the end of your phtml file(s):

    <?php
//unset catalog to allow using template for multiple categories on single page
Mage::unregister("_singleton/catalog/layer");
?>
  
?

Alternative way:

If you are on 1.4 or greater or 1.7EE or greater then this post is no longer valid as magento has moved to using widgets. You can find a featured product commercial widget here: http://www.magewidgets.com/featured-products-widget.html

?

If you want more in depth way, try to view this post: http://inchoo.net/ecommerce/magento/featured-products-on-magento-frontpage/

?

If you’re using Magento v1.1.5 or later, you might want to use these code snippets instead: http://www.magentocommerce.com/boards/viewthread/4780/P15/#t44262 This approach uses core functions instead of using Zend DB to figure out how to build a query statement.

?

from: http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/cms_and_home_page/add_featured_products_to_home_page

?

?

中文參考:

1. http://www.hellokeykey.com/magento-home-products/

2. http://sjolzy.cn/Add-New-products-in-the-Magento-CMS-Page-with-paging.html

3. http://www.hellokeykey.com/magento-change-product-list-display/

?

?

magento 首頁添加隨機產品 add a Random Featured Product list on home page in Magento


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 片在线观看免费观看视频 | 日韩免费视频观看 | 国产精品国产三级国产aⅴ入口 | 亚洲欧洲av在线 | 国产在线精品成人一区二区三区 | 亚洲天堂一级片 | 91成人影院未满十八勿入 | 亚洲一级毛片免费看 | www成人国产在线观看网站 | 五月天激激婷婷大综合丁香 | 天天躁夜夜躁狠狠躁2024 | 色窝视频 | 亚洲网站一区 | 91九色porn偷拍在线 | 天天摸天天做天天爽 | 99精品视频在线观看re | 日韩三级在线播放 | 国产成人99 | 久操色| 久久国产天堂福利天堂 | 欧美性video 日韩黄色视屏 | 精品欧美一区二区在线看片 | 成人高清 | 国内精品久久久久尤物 | 伊人9999| 国产91久久最新观看地址 | 日韩1区 | 亚洲欧美日韩精品久久奇米色影视 | 久久夜色精品国产亚洲噜噜 | 爱操影视| 丝袜诱惑中文字幕 | 99久久久国产精品免费99 | 欧美激情综合亚洲五月蜜桃 | 手机国产日韩高清免费看片 | 日本一级特黄a大片在线 | 久本草在线中文字幕亚洲欧美 | 欧美日韩国产色综合一二三四 | 国产精品高清在线观看 | 久久99精品视频 | 高清一区二区三区四区五区 | 欧美最新一区二区三区四区 |