在Magento中,提供了使用商品属性对产品进行筛选的功能,在分类页的侧栏中显示,如果没有设定好要进行筛选的属性,那么默认只显示 使用子分类进行产品筛选。筛选器的默认标题是 shop by
上图中的color属性是重新添加的,price属性是默认就开启的,但是全新安装的magento,加入产品后,并不会显示这个属性筛选,我们需要对属性进行设置才可以。 在后台选择属性管理
在 过滤器中搜索 price,并选择 price属性,
在 打开的属性修改页面,更改 Use In Layered Navigation属性
该属性有三个选项,
No: 该属性不作为筛选属性。
Filterable (with results) 作为筛选属性,只显示有结果的筛选项
Filterable (no results) 作为筛选属性,显示所有的筛选项,包括没有产品数量的筛选项。
设置,保存,更新index和缓存。
在分类页面上刷新,我们看到依然没有 price的属性筛选框,我们还有另外一个地方需要设置。
在产品分类的显示设置中 有一个 Is anchor (n.锚 v.抛锚,停泊;(使)固定)的选项设置,把该选项设为yes,保存,在查看一下,price筛选器就显示出来了。
,其他的属性,也是一样的设置方式,比如说,我们要对产品增加一个品牌的属性筛选,这个属性在默认的属性中并不存在,那么我们就要使用属性管理,新建一个属性,然后在把它设置成筛选属性。
参考
1 2 | //Magento 1.9x 自带的 模板 \app\design\frontend\rwd\ default \template\configurableswatches\catalog\layer\filter/swatches.phtml |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magento.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magento.com for more information. * * @category design * @package rwd_default * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> <?php /** * Template for filter items block * * @see Mage_Catalog_Block_Layer_Filter */ $_dimHelper = Mage::helper( 'configurableswatches/swatchdimensions' ); $_swatchInnerWidth = $_dimHelper ->getInnerWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER); $_swatchInnerHeight = $_dimHelper ->getInnerHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER); $_swatchOuterWidth = $_dimHelper ->getOuterWidth(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER); $_swatchOuterHeight = $_dimHelper ->getOuterHeight(Mage_ConfigurableSwatches_Helper_Swatchdimensions::AREA_LAYER); ?> <ol class = "configurable-swatch-list" > <?php foreach ( $this ->getItems() as $_item ): ?> <?php $_hasItems = ( $_item ->getCount() > 0); $_label = $_item ->getLabel(); $_swatchUrl = Mage::helper( 'configurableswatches/productimg' )->getGlobalSwatchUrl( $_item , $_label , $_swatchInnerWidth , $_swatchInnerHeight ); $_hasImage = (! empty ( $_swatchUrl )); $_linkClass = 'swatch-link' . (( $_hasImage ) ? ' has-image' : '' ); $_linkCss = 'height:' . $_swatchOuterHeight . 'px; ' . ((! $_hasImage ) ? 'min-' : '' ) . 'width:' . $_swatchOuterWidth . 'px;' ; $_lineHeight = $_swatchOuterHeight + 2; ?> <li<?php if ( $_hasImage ){ echo ' style="line-height: ' . $_lineHeight . 'px;"' ; } ?>> <?php if ( $_hasItems ): ?> <a href= "<?php echo $this->urlEscape($_item->getUrl()) ?>" class = "<?php echo $_linkClass ?>" > <?php else : ?> <span class = "<?php echo $_linkClass ?>" > <?php endif ; ?> <span class = "swatch-label" <?php if ( $_hasImage ){ echo ' style="' . $_linkCss . '"' ; } ?>> <?php if ( $_hasImage ): ?> <img src= "<?php echo $_swatchUrl; ?>" alt= "<?php echo $_label; ?>" title= "<?php echo $_label ?>" width= "<?php echo $_swatchInnerWidth ?>" height= "<?php echo $_swatchInnerHeight ?>" /> <?php else : ?> <?php echo $_label ; ?> <?php endif ; ?> </span> <?php if ( $this ->shouldDisplayProductCount()): ?> <span class = "count" >(<?php echo $_item ->getCount() ?>)</span> <?php endif ; ?> <?php if ( $_hasItems ): ?> </a> <?php else : ?> </span> <?php endif ; ?> </li> <?php endforeach ?> </ol> |
\app\design\frontend\rwd\default\layout/configurableswatches.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | <? xml version = "1.0" ?> <!-- /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magento.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magento.com for more information. * * @category design * @package rwd_default * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> < layout version = "0.1.0" > < product_list > < reference name = "head" > < action method = "addItem" >< type >skin_js</ type >< name >js/configurableswatches/product-media.js</ name ></ action > < action method = "addItem" >< type >skin_js</ type >< name >js/configurableswatches/swatches-list.js</ name ></ action > </ reference > < reference name = "product_list.name.after" > < block type = "core/template" name = "product_list.swatches" template = "configurableswatches/catalog/product/list/swatches.phtml" /> </ reference > < reference name = "product_list.after" > < block type = "configurableswatches/catalog_media_js_list" name = "configurableswatches.media.js.list" /> </ reference > </ product_list > < catalog_category_default > < update handle = "product_list" /> </ catalog_category_default > < catalog_category_layered > < update handle = "product_list" /> </ catalog_category_layered > < catalogsearch_result_index > < update handle = "product_list" /> </ catalogsearch_result_index > < catalogsearch_advanced_result > < update handle = "product_list" /> </ catalogsearch_advanced_result > < PRODUCT_TYPE_configurable > < reference name = "head" > < action method = "addItem" >< type >skin_js</ type >< name >js/configurableswatches/product-media.js</ name ></ action > < action method = "addItem" >< type >skin_js</ type >< name >js/configurableswatches/swatches-product.js</ name ></ action > </ reference > < reference name = "product.info.media" > < action method = "setGalleryFilterHelper" >< helper >configurableswatches/productimg</ helper ></ action > < action method = "setGalleryFilterMethod" >< method >filterImageInGallery</ method ></ action > </ reference > < reference name = "product.info.media.after" > < block type = "configurableswatches/catalog_media_js_product" name = "configurableswatches.media.js.product" /> </ reference > < reference name = "product.info.options.configurable.renderers" > < block type = "configurableswatches/catalog_product_view_type_configurable_swatches" template = "configurableswatches/catalog/product/view/type/options/configurable/swatches.phtml" /> </ reference > < reference name = "product.info.options.configurable.after" > < block type = "core/template" template = "configurableswatches/catalog/product/view/type/configurable/swatch-js.phtml" /> </ reference > </ PRODUCT_TYPE_configurable > </ layout > |
转载请注明:(●--●) Hello.My Weicot » Magento中产品属性筛选器 Use In Layered Navigation 说明 边栏调用 configurableswatches