Ecshop几个Xss漏洞修复

Ecshop pages.lbi.php Xss漏洞,search.php注入漏洞,Ecshop version XSS漏洞

Ecshop几个相关Xss漏洞
Ecshop pages.lbi.php Xss漏洞,search.php注入漏洞,Ecshop version XSS漏洞

1.Ecshop pages.lbi.php Xss漏洞

先来分析这个漏洞的原因:

直接访问temp/compiled/pages.lbi.php时,浏览源文件,会发现如下代码:

<form action=”temp/compiled/pages.lbi.php” method=”get”>

显然这个form是不完全的。当构造这样的url访问时,会造成在客户端执行代码:

temp/compiled/pages.lbi.php/”</form><sCripT>alert(/cfreer/)</scRipt>

很显然,这个漏洞的原理就是闭合了这个form再在客户端执行javascript.

然后分析出现不闭合form的原因,打开page.lbi.php文件,可以看到如下代码

<form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”get”> <?php if ($this->_var[‘pager’][‘styleid’] == 0): ?>

这里执行$this的时候就出现错误了,,因为没有进行template的初始化。

既然找到原因了,下面给出解决办法:

打开page.lbi文件,在第二行插入如下代码:

<?php if (!defined(‘IN_ECS’)) { die(‘Hacking attempt’); } ?>

2.search.php注入漏洞

search.php
大概300 源
if (is_not_null($val) )
修改为
if (is_not_null($val) && is_numeric($key))
就可以了

3.Ecshop version XSS漏洞

打开/admin/receive.php文件中,搜索如下代码:

$version=$_GET[‘version’];

修改为如下代码:

$version=htmlspecialchars($_GET[‘version’]);

Magento普通页面获取所有评论reviews

Magento在普通页面获取所有的评论reviews并分页显示

Magento在普通页面获取所有的评论reviews

下载附件:Allreviews

在目录app\code\local\Mage\Review\Block创建Allreviews.php

然后模板app\design\frontend\default\default\template\review

创建reviewslist.phtml

后台cms page中创建review然后content中调用
{{block type=”review/allreviews” template=”review/reviewslist.phtml”}}
访问
http://域名/review

参考互联网希望对大家有用

magento清空数据库log

magento清空数据库log

magento清空数据库log

truncate dataflow_batch_export;
truncate dataflow_batch_import;
truncate log_customer;
truncate log_quote;
truncate log_summary;
truncate log_summary_type;

truncate log_url;
truncate log_url_info;
truncate log_visitor;
truncate log_visitor_info;
truncate log_visitor_online;

truncate report_viewed_product_index;
truncate report_compared_product_index;
truncate report_event;

set foreign_key_checks = 0;
truncate index_process_event;
truncate index_event;
set foreign_key_checks = 1;

magento DUPLICATE ENTRY ” FOR KEY ‘UNQ_SALES_FLAT_ORDER_INCREMENT_ID’

问题可能出现在修改完订单编号后,提交订单到支付平台取消返回后继续提交,会出现类似

magento DUPLICATE ENTRY ” FOR KEY ‘UNQ_SALES_FLAT_ORDER_INCREMENT_ID’

问题可能出现在修改完订单编号后,提交订单到支付平台取消返回后继续提交,会出现类似

 

magento DUPLICATE ENTRY ” FOR KEY ‘UNQ_SALES_FLAT_ORDER_INCREMENT_ID’

解决办法

/app/code/core/Mage/Sales/Model/Resource/Quote.php

 

public function isOrderIncrementIdUsed($orderIncrementId)Line number 146

$bind = array (‘:increment_id’ => (int) $orderIncrementId);

Replace it with below line

$bind      = array(‘:increment_id’ => $orderIncrementId);

 

希望有帮助!!!

 

ecshop the table ‘ecs_sessions’ is full

访问ECSHOP网站的时,突然会出现下面错误提示:ecshop the table ‘ecs_sessions’ is full

访问ECSHOP网站的时,突然会出现下面错误提示:

MySQL server error report:Array ( [0] => Array ( [message] => MySQL Query Error ) [1] => Array ( [sql] => INSERT INTO `howjia`.`hsd_sessions` (sesskey, expiry, ip, data) VALUES (’6e29308d83asdf3f30446122f49e89023156′, ’1297816061′, ’14.239.213.116′, ‘a:0:{}’) ) [2] => Array ( [error] => The table ‘ecs_sessions’ is full ) [3] => Array ( [errno] => 1114 ) )

解决方案:

1.根据错误提示判断是ecs_sessions表满了,打开ecs_sessions表,清理一些数据或者全部清空。

2.通过程序设置可以解决这个问题。

程序解决方法是:

设置includes/cls_session.php里的

var $max_life_time = 800,

这个数值根据网站访问量的大小来定,访问越大可以设置的越小。

Magento产品页面404

大家有时候会使用sql语句:

TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_summary_type`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
TRUNCATE `log_visitor_online`;
TRUNCATE `report_event`;
TRUNCATE `report_event_types`;

清空Magento的数据库日志;这个可能导致Magento产品页面访问404,解决办法

执行sql语句

INSERT INTO `report_event_types` (`event_type_id`, `event_name`, `customer_login`) VALUES
(1, 'catalog_product_view', 1),
(2, 'sendfriend_product', 1),
(3, 'catalog_product_compare_add_product', 1),
(4, 'checkout_cart_add_product', 1),
(5, 'wishlist_add_product', 1),
(6, 'wishlist_share', 1);

解决Magento一页支付IWD Free One Page & One Step Checkout插件里订单留言不发送邮件

Magento免费的一页支付插件(IWD Free One Page & One Step Checkout)安装完之后有一个comment的表单,默认在后台是关闭的,打开后好让客户能在下单的同时留言,对订单的补充。
打开之后后台里可以看到留言,但是订单邮件里没有留言,后面经过查看代码,发现magento一页支付插件默认是不发送留言到邮件里的,之后安装另外的订单留言插件对比下看里面少了一些发送留言到邮件的代码。
需要在一页支付插件IWD的文件夹目录下找到 observer.php 文件,并在函数addHistoryComment 里增加几行代码即可,代码如下红色字体。

Magento免费的一页支付插件(IWD Free One Page & One Step Checkout)安装完之后有一个comment的表单,默认在后台是关闭的,打开后好让客户能在下单的同时留言,对订单的补充。
打开之后后台里可以看到留言,但是订单邮件里没有留言,后面经过查看代码,发现magento一页支付插件默认是不发送留言到邮件里的,之后安装另外的订单留言插件对比下看里面少了一些发送留言到邮件的代码。
需要在一页支付插件IWD的文件夹目录下找到IWD/OnepageCheckout/Model/ observer.php 文件,并在函数addHistoryComment 里增加几行代码即可,代码如下红色字体。

public function addHistoryComment($data)
{
$comment = Mage::getSingleton('customer/session')->getOrderCustomerComment();
$comment = trim($comment);

if (!empty($comment))
{
$data['order']->addStatusHistoryComment($comment)->setIsVisibleOnFront(true)->setIsCustomerNotified(false);
//added these lines:
$order = $data->getEvent()->getOrder();
 $order->setCustomerComment($comment);
 $order->setCustomerNoteNotify(true);
 $order->setCustomerNote($comment);
}
}

如果没反应,在修改邮件模板

app/locale/en_US/template/email/sales/下

order_new.html

order_new_guest.html

在里边找适当位置添加

{{var order.getOnestepcheckoutCustomercomment()}}

Magento获取产品ID,根据ID获取产品信息

Magento获取产品ID,根据ID获取产品信息

Magento获取产品ID,根据ID获取产品信息,如果想在产品页面的其他相关页面,比如左侧、头部、底部获取产品的信息:
如果知道ID是最好的,但是不知道的情况下,我们可以先获取当前产品id

$product_id = Mage::registry(‘current_product’)->getId();
$_product = Mage::getModel(‘catalog/product’)->load($product_id);

可以先判断是否为产品页面

if (Mage::registry(‘product’)){/**/}//先获取是否为产品页面

然后直接获取产品相关信息

echo $_product->getShortDescription(); //product’s short description
echo $_product->getDescription(); // product’s long description
echo $_product->getName(); //product name
echo $_product->getPrice(); //product’s regular Price
echo $_product->getSpecialPrice(); //product’s special Price
echo $_product->getProductUrl(); //product url
echo $_product->getImageUrl(); //product’s image url
echo $_product->getSmallImageUrl(); //product’s small image url
echo $_product->getThumbnailUrl(); //product’s thumbnail image url

Magento一些实用插件,Magento常用插件整理

Magento一些实用插件,Magento常用插件整理:挺有用的

Magento一些实用插件,Magento常用插件整理:挺有用的

53. 全页缓存插件
一:Lesti::Fpc
URL:http://www.magentocommerce.com/magento-connect/lesti-fpc-4534.html
KEY:http://connect20.magentocommerce.com/community/Lesti_Fpc

52. Magento 价格小数位管理
一:Price Layout Extension
URL:http://www.magentocommerce.com/magento-connect/price-layout-extension.html
KEY1:magento-community/wp_price_decimal
KEY2:http://connect20.magentocommerce.com/community/wp_price_decimal
二:ET Currency Manager
URL:http://www.magentocommerce.com/magento-connect/et-currency-manager.html
KEY1:magento-community/ET_CurrencyManager
KEy2:http://connect20.magentocommerce.com/community/ET_CurrencyManager

51. 丰富网页内容(与36同类型)
URL:http://www.magentocommerce.com/magento-connect/msemantic-semantic-seo-for-rich-snippets-in-google-and-yahoo.html
KEY1:magento-community/Semantium_MSemanticBasic
KEY2:http://connect20.magentocommerce.com/community/Semantium_MSemanticBasic

50. 漂亮左侧菜单导航
URL:http://www.magentocommerce.com/magento-connect/mtoo-advance-left-vertical-navigation-with-nice-css-design-6858.html
KEY:http://connect20.magentocommerce.com/community/Advance_Left_Vertical_Navigation

49. 属性组切换插件
URL:http://www.magentocommerce.com/magento-connect/flagbit-change-attribute-set.html
KEY1:magento-community/Flagbit_ChangeAttributeSet
KEY2:http://connect20.magentocommerce.com/community/Flagbit_ChangeAttributeSet

48. A-Z 排序插件 for 1.3_1.4
URL:http://www.magentocommerce.com/magento-connect/alphabates.html
KEY:magento-community/alphabates

47. 清理无用图片
URL:http://www.magentocommerce.com/magento-connect/image-clean.html
KEY2:http://connect20.magentocommerce.com/community/Mage_Imaclean

46. 广告推荐热卖产品
URL:http://www.magentocommerce.com/magento-connect/catalog/product/view/id/14745/s/advertise-upsell-products-5581/
KEY2:http://connect20.magentocommerce.com/community/AdvertiseUpsellProducts

45. 广告推荐产品(自动关联相关、交叉、热卖产品)
URL:http://www.magentocommerce.com/magento-connect/catalog/product/view/id/14924/s/advertise-suggested-products-2487/
KEY2:http://connect20.magentocommerce.com/community/AdvertiseSuggestedProducts

44. Facebook Store 插件
URL:http://www.magentocommerce.com/magento-connect/facebook-products-tab.html
KEY1:magento-community/Facebook_Products_Tab
KEY2:http://connect20.magentocommerce.com/community/Facebook_Products_Tab

43. 快速购物
URL1:http://www.magentocommerce.com/magento-connect/quickview-7580.html
KEY1:magento-community/Quickview
KEY2:http://connect20.magentocommerce.com/community/Quickview

URL2:http://www.magentocommerce.com/magento-connect/em-quick-shop-quick-view-product.html
KEY1:magento-community/EM_Quickshop
KEY2:http://connect20.magentocommerce.com/community/EM_Quickshop

42. 搜索结果预览
URL:http://www.magentocommerce.com/magento-connect/search-autocomplete-8858.html
KEY1:magento-community/Searchautocomplete
KEY2:http://connect20.magentocommerce.com/community/Searchautocomplete

41. 自定义属性复制
URL:http://www.magentocommerce.com/magento-connect/custom-options-replicator.html
KEY2:http://connect20.magentocommerce.com/community/ZetaPrints_Options

40. Enhanced Admin Product Grid 增强产品管理
URL:http://www.magentocommerce.com/magento-connect/enhanced-admin-product-grid.html
KEY1:magento-community/TBT_Enhancedgrid
KEY2:http://connect20.magentocommerce.com/community/TBT_Enhancedgrid
附:插件设置的页面404错误修复
app/code/community/TBT/Enhancedgrid/Model/System/Config/Source/Columns/Show.php
第 10 行,将 “->addVisibleFilter();” 换成 “->addFilter(“is_visible”, 1);”

39. 客户反馈
URL:http://www.magentocommerce.com/magento-connect/feedback-1959.html
KEY1:magento-community/bc_feedback
KEY2:http://connect20.magentocommerce.com/community/bc_feedback

38. 单页结账
URL:http://www.magentocommerce.com/magento-connect/iwd-free-one-page-step-checkout-6454.html
KEY2:http://connect20.magentocommerce.com/community/1213

37. ASchroder SMTP Pro
URL:http://www.magentocommerce.com/magento-connect/aschroder-com-smtp- pro-email-free-and-easy-magento-emailing-for-smtp-gmail-or-google-apps-email.html
KEY1:magento-community/ASchroder_SMTPPro
KEY2:http://connect20.magentocommerce.com/community/ASchroder_SMTPPro

36. Google 产品微标记
URL:http://www.magentocommerce.com/magento-connect/ayaline-rich-snippets-1339.html
KEY1:magento-community/Ayaline_RichSnippets
KEY2:http://connect20.magentocommerce.com/community/Ayaline_RichSnippets

35. 支付方式过滤
URL:http://www.magentocommerce.com/magento-connect/paymentfilter-for-products-and-customer-groups.html
KEY1:magento-community/RicoNeitzel_PaymentFilter
KEY2:http://connect20.magentocommerce.com/community/RicoNeitzel_PaymentFilter

34. 属性选项导入插件
URL:http://www.magentocommerce.com/magento-connect/attribute-options-add-6435.html
KEY:http://connect20.magentocommerce.com/community/Tds_Attributeoptionupdate

33. 分类访问控制
URL:http://www.magentocommerce.com/magento-connect/category-access-control.html
KEY1:magento-community/category_access_control
KEY2:http://connect20.magentocommerce.com/community/category_access_control
卸载需要运行:
DELETE FROM `eav_attribute` WHERE attribute_code LIKE ‘accesscontrol_show_group%’;
DELETE FROM `core_resource` WHERE code=’accesscontrol_setup’;

32. 邮件订阅分组
URL:http://www.magentocommerce.com/magento-connect/newsletter-groups-8781.html
KEY1:magento-community/Fsite_NewsletterGroup
KEY2:http://connect20.magentocommerce.com/community/Fsite_NewsletterGroup

31. 分享优惠
URL:http://www.magentocommerce.com/magento-connect/social-power-share.html
KEY1:magento-community/Social_Power_Share
KEY2:http://connect20.magentocommerce.com/community/Social_Power_Share

30. 访问最多的产品
URL:http://www.magentocommerce.com/magento-connect/product-slider-9077.html
KEY1:magento-community/BP_Mostviewed
KEY2:http://connect20.magentocommerce.com/community/BP_Mostviewed

29. 清理 Magento
URL:http://www.magentocommerce.com/magento-connect/magentoo-magentools.html
KEY:magento-community/Magentoo_Magentools

28. 验证码插件
URL:http://www.magentocommerce.com/magento-connect/outsourceonline-captcha-6034.html
KEY1:magento-community/OutsourceOnline_Captcha
KEy2:http://connect20.magentocommerce.com/community/OutsourceOnline_Captcha
另外一个
URL:http://www.magentocommerce.com/magento-connect/i95dev-captcha.html

27. 特价倒计时
URL:http://www.magentocommerce.com/magento-connect/price-countdown.html
KEY1:magento-community/Price_Countdown
KEY2:http://connect20.magentocommerce.com/community/Price_Countdown

26. Groups Catalog 隐藏分类和产品 (1.4 – 1.5 -1.6 )
1.4-1.5
URL:http://www.magentocommerce.com/magento-connect/netzarbeiter-groupscatalog.html
KEY1:magento-community/Netzarbeiter_GroupsCatalog
KEY2:http://connect20.magentocommerce.com/community/Netzarbeiter_GroupsCatalog
1.6
URL:http://www.magentocommerce.com/magento-connect/customer-groups-catalog2-4585.html
URL2:http://connect20.magentocommerce.com/community/Netzarbeiter_GroupsCatalog2

25. 订单咨询插件
URL:http://www.magentocommerce.com/magento-connect/site-management/customer-service/order-tickets.html
KEY1:magento-community/Order_tickets
KEY2:http://connect20.magentocommerce.com/community/Order_tickets

24. 给“联系我们”页添加一个调查表单
URL:http://www.magentocommerce.com/magento-connect/site-management/customer-service/webforms-community-edition.html
KEY1:magento-community/WebForms
KEY2:http://connect20.magentocommerce.com/community/WebForms

23. 首页产品
URL:http://www.magentocommerce.com/magento-connect/homesellers-5in1-free.html
KEY1:magento-community/Magazento_Homesellers
KEY2:http://connect20.magentocommerce.com/community/Magazento_Homesellers

22. 热卖产品插件
URL:http://www.magentocommerce.com/magento-connect/easy-topsellers-free.html
KEY1:magento-community/Easy_Topsellers
KEY2:http://connect20.magentocommerce.com/community/Easy_Topsellers
URL2:http://www.magentocommerce.com/magento-connect/bestseller-products-7401.html
URL3:http://www.magentocommerce.com/magento-connect/vs-bestseller-7235.html
URL4:http://www.magentocommerce.com/magento-connect/votum-bestseller.html
URL5:http://www.magentocommerce.com/magento-connect/jextn-bestselling-products-1455.html
URL6:http://www.magentocommerce.com/magento-connect/catalog/product/view/id/13946/s/custom-listings-7646/
URL7:http://www.magentocommerce.com/magento-connect/catalog/product/view/id/14095/s/product-slider-9572/
URL8:http://www.magentocommerce.com/magento-connect/catalog/product/view /id/13827/s/magento-mostviewed-mostpopular-products-free-7566/

21. 西联支付插件
URL:http://www.magentocommerce.com/magento-connect/atwix-western-union-payment-method.html
KEY2:http://connect20.magentocommerce.com/community/Atwix_Western_Union_Payment_Method
KEY1:magento-community/Atwix_Western_Union_Payment_Method

20. 给品牌属性添加图片
URL:http://www.magentocommerce.com/magento-connect/manufacturer-1679.html
KEY:http://connect20.magentocommerce.com/community/manufacturer-community

19. 给联系我们添加附件
URL:http://www.magentocommerce.com/magento-connect/contact-form-attachment-7158.html
KEY:http://connect20.magentocommerce.com/community/ContactFormAttachment

18. 完美图片形象
URL:http://www.magentocommerce.com/magento-connect/picture-perfect-mass-product-image-uploader-6636.html
KEY:http://connect20.magentocommerce.com/community/pictureperfect_wexo

17. 图片显示库存状态
URL:http://www.magentocommerce.com/magento-connect/xogenics-stock-status-images.html
KEY1:magento-community/Xogenics_StockStatusImages
KEY2:http://connect20.magentocommerce.com/community/Xogenics_StockStatusImages

16. 运费规则管理
URL:http://www.magentocommerce.com/magento-connect/shipping-table-rates.html
KEY:http://connect20.magentocommerce.com/community/ShippingTablerate

15. 侧边栏显示评论(插件两个)
URL:http://www.magentocommerce.com/magento-connect/reviews-sidebar.html
KEY1:magento-community/Reviews_Sidebar
KEY2:http://connect20.magentocommerce.com/community/Reviews_Sidebar
URL:http://www.magentocommerce.com/magento-connect/vs-sidebarreview.html
KEY1:magento-community/VS_Sidebarreview
KEY2:http://connect20.magentocommerce.com/community/VS_Sidebarreview

14. 产品附件
URL:http://www.magentocommerce.com/magento-connect/product-attachments-extension.html
KEY1:magento-community/ProductAttachments_Module
KEY2:http://connect20.magentocommerce.com/community/ProductAttachments_Module

13. 更加友好的图片名称
URL:http://www.magentocommerce.com/magento-connect/netzarbeiter-nicerimagenames.html
KEY:http://connect20.magentocommerce.com/community/Netzarbeiter_NicerImageNames

12. 迷你弹窗登陆
URL:http://www.magentocommerce.com/magento-connect/giko-ajaxlogin.html
KEY2:http://connect20.magentocommerce.com/community/Giko_AjaxLogin

11. 允许客户在产品页上传一个附件
URL:http://www.magentocommerce.com/magento-connect/dynamic-file-attachments.html
KEY:http://connect20.magentocommerce.com/community/ZetaPrints_Attachments

10. 自定义分层导航风格
URL:http://www.magentocommerce.com/magento-connect/custom-layered-navigation-style.html
KEY2:http://connect20.magentocommerce.com/community/Custom_Layered_Navigation
KEY1:magento-community/Custom_Layered_Navigation

9. 移动管理插件
URL:http://www.magentocommerce.com/magento-connect/customer-experience/mobile/mobileadmin-7554.html
KEY:http://connect20.magentocommerce.com/community/snm_mobileadminc

8. 关联产品管理 自动设置交叉、热卖、相关产品
URL:http://www.magentocommerce.com/magento-connect/related-proudcts-manager-7301.html
KEY:http://connect20.magentocommerce.com/community/CommerceStack_Recommender

7. 简单评论模板插件
URL: http://www.magentocommerce.com/magento-connect/site-management/order-management/easycomments-3534.html
KEY1:magento-community/EasyComments
KEY2:http://connect20.magentocommerce.com/community/EasyComments

6. 退货插件
URL:http://www.magentocommerce.com/magento-connect/site-management/order-management/returnslink-rma-2707.html
KEY2:http://connect20.magentocommerce.com/community/ReturnsLink

5. Magento 移动插件
URL:http://www.magentocommerce.com/magento-connect/magento-mobile-6497.html
KEY1:magento-core/Magento_Mobile
KEY2:http://connect20.magentocommerce.com/community/Magento_Mobile

4. Magento 博客插件
URL:http://www.magentocommerce.com/magento-connect/blog-community-edition.html
KEY1:magento-community/AW_Blog
KEY2:http://connect20.magentocommerce.com/community/AW_Blog

3. 自定项友好切换插件
URL:http://www.magentocommerce.com/magento-connect/gala-color-swatches-free-9787.html
KEY1:magento-community/Gala_Colorswatches
KEY2:http://connect20.magentocommerce.com/community/Gala_Colorswatches

2. 导入产品关联,交叉销售,热卖推荐关系 ( ERIC 分享 )
URL:http://www.magentocommerce.com/magento-connect/itib-mass-import-product-relations-upsell-and-cross-sell.html
KEY2: http://connect20.magentocommerce.com/community/ITIB_MassImportProductRelations
KEY1: magento-community/ITIB_MassImportProductRelations

1. 商品按库存排序
URL: http://www.magentocommerce.com/magento-connect/customer-experience/category-product-page-enhancements/sort-products-by-stock-status-9821.html
KEY2:http://connect20.magentocommerce.com/community/Rayfox_Catalog

Magento产品列表增加A-Z字母过滤功能

Magento如何将产品列表增加A-Z字母过滤功能

Magento如何将产品列表增加A-Z字母过滤功能,字母过滤对seo也有一定的帮助
首先把
app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
复制到
app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php

1

 

 

然后增加一个函数

01
02
03
04
05
06
07
08
09
10
public
function
str_replace_once(
$needle
, 
$replace
, 
$haystack
){
 
// Looks for the first occurence of $needle in $haystack
 
// and replaces it with $replace.
 
$pos
= 
strpos
(
$haystack
, 
$needle
);
 
if
(
$pos
=== false) {
 
// Nothing found
 
return
$haystack
;
 
}
 
return
substr_replace(
$haystack
, 
$replace
, 
$pos
, 
strlen
(
$needle
));
 
}

然后将以下函数换在如下代码

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
public
function
setCollection(
$collection
){
 
$this
->_collection = 
$collection
;
 
$this
->_collection->setCurPage(
$this
->getCurrentPage());
 
// we need to set pagination only if passed value integer and more that 0
 
$limit
= (int)
$this
->getLimit();
 
$postData
= ”;
 
if
(
$limit
) {
 
$this
->_collection->setPageSize(
$limit
);
 
}
 
if
(
$this
->getCurrentOrder()){
 
/////Alphabate search Code Start From here.
 
$postData
= Mage::app()->getRequest()->getParam(‘alpha’).’%';
 
$postData_all
= Mage::app()->getRequest()->getParam(‘alpha’);
 
if
(isset(
$postData_all
) && 
$postData_all
!= ” && trim(
$postData_all
) !=’ALL’){
 
$this
->_collection->setOrder(
$this
->getCurrentOrder(), 
$this
->getCurrentDirection())
 
->addAttributeToFilter(
array
(
array
(‘attribute’=>’name’, ‘like’=>
$postData
)  ));
 
}
else
{
 
$this
->_collection->setOrder(
$this
->getCurrentOrder(), 
$this
->getCurrentDirection());
 
}
////Code End
 
}
 
return
$this
;
 
}

在app/design/frontend/default/default/template/catalog/product/list/toolbar.phtml

尾部增加如下代码如可:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
<
div
>
 
<
p
>
 
<?
php
 
$
postData
= 
Mage
::app()->getRequest()->getParam(‘alpha’);
 
foreach ($search_array  as $search_array_value):
 
if (strstr( $this->helper(‘core/url’)->getCurrentUrl(), “?” )){
 
$final_Url =  $this->str_replace_once(‘&’,'?’,str_replace
 
(“?alpha=”.trim($postData['alpha']),”,str_replace($make_nbsp.
 
“alpha=”.trim($postData['alpha']),”,$this->helper(‘core/url’)->getCurrentUrl())));
 
}else{
 
$final_Url = str_replace(“?alpha=”.trim($postData['alpha']),”,
 
str_replace($make_nbsp.”alpha=”.trim($postData['alpha']),”,
 
$this->helper(‘core/url’)->getCurrentUrl()));    }?>
 
<
a
href=”<?php echo $final_Url.$make_nbsp.’alpha=’.$search_array_value;?>”
 
title=”<?
php
echo $_label ?>”><?
php
echo $search_array_value; ?></
a
>&nbsp;&nbsp;
 
<?
php
endforeach; ?>
 
</
p
>
 
</
div
>

好了,完成了Magento产品列表增加A-Z字母过滤功能.

转载自Magento • 解百纳