<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Magento及Web前端开发</title>
	<atom:link href="http://www.magentofront-end.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.magentofront-end.com</link>
	<description>magento相关内容及对前端开发的一些心得</description>
	<lastBuildDate>Tue, 31 Jan 2012 09:00:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Magento与wordpress整合插件-WordPress Integration</title>
		<link>http://www.magentofront-end.com/magentomuban/318</link>
		<comments>http://www.magentofront-end.com/magentomuban/318#comments</comments>
		<pubDate>Tue, 31 Jan 2012 09:00:52 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento插件]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=318</guid>
		<description><![CDATA[最近在折腾Magento与wordpress的整合。在朋友的推荐下今天装了WordPress Integration这个插件。安装方法很简单，首先在Magento根目录下安装wordpress。数据库可以新建一个，也可以使用Magento的。然后安装这个插件就好。如果你使用的是独立数据库，需要在后台设置下，否则无法连接到数据库。Magento 后台wordpress-&#62;Settings-&#62;Database/Integration，中设置下。 看了下插件的官方文档，常用的一些wordpress插件都是支持的，具体的使用方法和效果，以后再分享。刚装上插件，还没玩……]]></description>
			<content:encoded><![CDATA[<p>最近在折腾<strong>Magento与wordpress的整合</strong>。在朋友的推荐下今天装了<a rel="nofollow" href="http://www.magentocommerce.com/magento-connect/fishpig/extension/3958/fishpig_wordpress_integration"><strong>WordPress Integration</strong></a>这个插件。安装方法很简单，首先在Magento根目录下安装wordpress。数据库可以新建一个，也可以使用Magento的。然后安装这个插件就好。如果你使用的是独立数据库，需要在后台设置下，否则无法连接到数据库。Magento 后台wordpress-&gt;Settings-&gt;Database/Integration，中设置下。</p>
<p><img class="alignnone size-full wp-image-320" title="Magento-wordpress整合" src="http://www.magentofront-end.com/wp-content/uploads/2012/01/wordpress.gif" alt="Magento-wordpress整合" width="521" height="200" /></p>
<p>看了下插件的官方文档，常用的一些wordpress插件都是支持的，具体的使用方法和效果，以后再分享。刚装上插件，还没玩……</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/318/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento seo优化——让产品链接唯一</title>
		<link>http://www.magentofront-end.com/magentomuban/313</link>
		<comments>http://www.magentofront-end.com/magentomuban/313#comments</comments>
		<pubDate>Wed, 07 Sep 2011 02:50:17 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=313</guid>
		<description><![CDATA[在Magento后台会默认开启Use Categories Path for Product URLs。 这时候产品链接就会变成两个http://127.0.0.1/magentoyouhua/index.php/furniture/living-room/ottoman.html，http://127.0.0.1/magentoyouhua/index.php/ottoman.html。两个链接同时链向一个页面时，这样对seo是不好的。解决方法： 一、在后台关闭这个功能。 二、修改php文件去除分类url路径，因为在关闭这个功能后，一些插件还是会自带分类url路径。打开app/code/core/Mage/Catalog/Model/url.php 找到 1 2 3 4 5 6 7 8 9 10 11 12 13 if &#40;null === $parentPath&#41; &#123; $parentPath = $this-&#62;getResource&#40;&#41;-&#62;getCategoryParentPath&#40;$category&#41;; &#125; elseif &#40;$parentPath == '/'&#41; &#123; $parentPath= ''; &#125; 修改成 //if (null === $parentPath) { //$parentPath = $this-&#62;getResource()-&#62;getCategoryParentPath($category); //} //elseif ($parentPath == '/') { [...]]]></description>
			<content:encoded><![CDATA[<p>在<a title="magento seo优化" href="http://www.magentofront-end.com"><strong>Magento</strong></a>后台会默认开启Use Categories Path for Product URLs。<br />
<img src="http://www.magentofront-end.com/wp-content/uploads/2011/09/magento-seo.jpg" alt="magento-seo优化" title="magento-seo" width="539" height="281" class="alignnone size-full wp-image-314" /><br />
这时候产品链接就会变成两个http://127.0.0.1/magentoyouhua/index.php/<span style="color: #ff0000;">furniture/living-room</span>/ottoman.html，http://127.0.0.1/magentoyouhua/index.php/ottoman.html。两个链接同时链向一个页面时，这样对seo是不好的。解决方法：<br />
一、在后台关闭这个功能。<br />
二、修改php文件去除分类url路径，因为在关闭这个功能后，一些插件还是会自带分类url路径。打开app/code/core/Mage/Catalog/Model/url.php<br />
找到</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">===</span> $parentPath<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
$parentPath <span style="color: #339933;">=</span> $this<span style="color: #339933;">-&gt;</span>getResource<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>getCategoryParentPath<span style="color: #009900;">&#40;</span>$category<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
elseif <span style="color: #009900;">&#40;</span>$parentPath <span style="color: #339933;">==</span> <span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
$parentPath<span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
修改成
<span style="color: #006600; font-style: italic;">//if (null === $parentPath) {</span>
<span style="color: #006600; font-style: italic;">//$parentPath = $this-&gt;getResource()-&gt;getCategoryParentPath($category);</span>
<span style="color: #006600; font-style: italic;">//}</span>
<span style="color: #006600; font-style: italic;">//elseif ($parentPath == '/') {</span>
$parentPath<span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//}</span></pre></td></tr></table></div>

<p>然后刷新下索引就可以了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/313/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>可筛选下拉框在Magento商城中的应用</title>
		<link>http://www.magentofront-end.com/magentomuban/290</link>
		<comments>http://www.magentofront-end.com/magentomuban/290#comments</comments>
		<pubDate>Mon, 13 Dec 2010 10:35:56 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[前端相关]]></category>
		<category><![CDATA[伪select]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=290</guid>
		<description><![CDATA[在Magento添加可配置产品的时候，某一属性如果选项很多，我们就要盯着下拉框一个一个扫描下去了，这样会崩溃的。我用jQuery写了个可以对属性进行筛选的方法。实现原理就是弄了个假的select选择框覆盖在上面。先看下事例图。 未进行筛选的下拉框 筛选后的下拉框 在app/design/adminhtml/default/default/template/cagalog/product /edit/super/config.phtml加入以下代码. 其中#simple_product_huaxing是select的id，改为你的select的iD即可 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 &#60;div id=&#34;huase&#34;&#62; &#60;div id=&#34;selecthuaxin&#34;&#62;&#60;input type=&#34;text&#34; /&#62;&#60;/div&#62; &#60;/div&#62; &#60;script type=&#34;text/javascript&#34;&#62;// &#60;![CDATA[ jQuery&#40;&#34;#huase&#34;&#41;.insertBefore&#40;&#34;#simple_product_huaxing&#34;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>在<a href="http://www.magentofront-end.com">Magento</a>添加可配置产品的时候，某一属性如果选项很多，我们就要盯着下拉框一个一个扫描下去了，这样会崩溃的。我用jQuery写了个可以对属性进行筛选的方法。实现原理就是弄了个假的select选择框覆盖在上面。先看下事例图。<br />
<strong>未进行筛选的下拉框</strong><br />
<img class="alignnone size-full wp-image-296" title="magento-select1" src="http://www.magentofront-end.com/wp-content/uploads/2010/12/magento-select1.jpg" alt="Magento-select" width="366" height="290" /><br />
<strong>筛选后的下拉框</strong><br />
<img class="alignnone size-full wp-image-297" title="magento-select2" src="http://www.magentofront-end.com/wp-content/uploads/2010/12/magento-select2.jpg" alt="magento-select" width="366" height="165" /><br />
在<em>app/design/adminhtml/default/default/template/cagalog/product /edit/super/config.phtml</em>加入以下代码.<br />
其中#simple_product_huaxing是select的id，改为你的select的iD即可</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;div id=&quot;huase&quot;&gt;
&lt;div id=&quot;selecthuaxin&quot;&gt;&lt;input type=&quot;text&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #006600; font-style: italic;">// &lt;![CDATA[</span>
 jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#huase&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#simple_product_huaxing&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#selecthuaxin input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">keyup</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> inputval<span style="color: #339933;">=</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#weiselect li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#simple_product_huaxing option:contains(&quot;</span><span style="color: #339933;">+</span>inputval<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> selecton<span style="color: #339933;">=</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> opval<span style="color: #339933;">=</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> li<span style="color: #339933;">=</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;
&nbsp;
	&lt;li /&gt;&quot;</span><span style="color: #009900;">&#41;</span>
li.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>selecton<span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#weiselect&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span>
li.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>opval<span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#weiselect li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> lion<span style="color: #339933;">=</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class&quot;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #003366; font-weight: bold;">var</span> litext<span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#simple_product_huaxing&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>lion<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#selecthuaxin input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>litext<span style="color: #009900;">&#41;</span>
 jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#weiselect li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#simple_product_huaxing&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> selcted<span style="color: #339933;">=</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#simple_product_huaxing option:selected&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#selecthuaxin input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>selcted<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#weiselect li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>background<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#2E4A99&quot;</span><span style="color: #339933;">,</span>color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#fff&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>background<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#fff&quot;</span><span style="color: #339933;">,</span>color<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;#000&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span> 
&nbsp;
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #006600; font-style: italic;">// ]]&gt;&lt;/script&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/290/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Magento注册验证加强</title>
		<link>http://www.magentofront-end.com/magentomuban/282</link>
		<comments>http://www.magentofront-end.com/magentomuban/282#comments</comments>
		<pubDate>Thu, 09 Dec 2010 05:37:59 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento注册验证]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=282</guid>
		<description><![CDATA[Magento有自带的一个验证机制，但是用起来，用户体验不太好，Magento是在点击提交按钮以后才开始验证的。良好的用户体验是在客户提交表单前就提出错误的地方，可以去玩下淘宝的注册。 我先讲下Magento自带的验证机制的使用方法，首页看下js/prototype/validation.js，整个网站的验证相关的东西都写这里面，有能力的可以直接在这里面改，改成你想要的模式。Magento是通过class名来触发这个验证。我以注册页面为例，先看下注册页面的Email的html 1 &#60;input type=&#34;text&#34; class=&#34;input-text validate-email required-entry&#34; id=&#34;email_address&#34; name=&#34;email&#34;&#62; required-entry说明这个是必填项，validate-email说明这个是邮箱验证。如果你想在其他的地方做这些验证 只要加上这两个class就行。 我在Magento的基础上，用jQuery做了点判断，做成类似淘宝的了。 我是通过blur事件来触发的，隐藏和显示div达到这个效果，下面发一些判断的正则。 判断电话号码，手机，座机一起判断的 1 &#40;&#40;\d&#123;11&#125;&#41;&#124;^&#40;&#40;\d&#123;7,8&#125;&#41;&#124;&#40;\d&#123;4&#125;&#124;\d&#123;3&#125;&#41;-&#40;\d&#123;7,8&#125;&#41;&#124;&#40;\d&#123;4&#125;&#124;\d&#123;3&#125;&#41;-&#40;\d&#123;7,8&#125;&#41;-&#40;\d&#123;4&#125;&#124;\d&#123;3&#125;&#124;\d&#123;2&#125;&#124;\d&#123;1&#125;&#41;&#124;&#40;\d&#123;7,8&#125;&#41;-&#40;\d&#123;4&#125;&#124;\d&#123;3&#125;&#124;\d&#123;2&#125;&#124;\d&#123;1&#125;&#41;&#41;$&#41; 判断邮编 1 ^&#91;0-9&#93;&#123;6&#125;$ 判断邮箱 1 ^&#40;&#91;a-zA-Z0-9&#93;+&#91;_&#124;\_&#124;\.&#93;?&#41;*&#91;a-zA-Z0-9&#93;+@&#40;&#91;a-zA-Z0-9&#93;+&#91;_&#124;\_&#124;\.&#93;?&#41;*&#91;a-zA-Z0-9&#93;+\.&#91;a-zA-Z&#93;&#123;2,3&#125;$ 详细的js和phtml我就不说明了，js写的有点烂，放个链接，有兴趣的可以看下 JQUERY，PHTML]]></description>
			<content:encoded><![CDATA[<p><strong><a title="Magento" href="http://www.magentofront-end.com">Magento</a></strong>有自带的一个验证机制，但是用起来，用户体验不太好，Magento是在点击提交按钮以后才开始验证的。良好的用户体验是在客户提交表单前就提出错误的地方，可以去玩下淘宝的注册。</p>
<p>我先讲下Magento自带的验证机制的使用方法，首页看下js/prototype/validation.js，整个网站的验证相关的东西都写这里面，有能力的可以直接在这里面改，改成你想要的模式。Magento是通过class名来触发这个验证。我以注册页面为例，先看下注册页面的Email的html</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;input-text validate-email required-entry&quot;</span>  id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email_address&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span><span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>required-entry说明这个是必填项，validate-email说明这个是邮箱验证。如果你想在其他的地方做这些验证 只要加上这两个class就行。<br />
我在Magento的基础上，用jQuery做了点判断，做成类似淘宝的了。<img src="http://www.magentofront-end.com/wp-content/uploads/2010/12/magento-zhuce.jpg" alt="Magento注册" title="magento-zhuce" width="539" height="285" class="size-full wp-image-285" /><br />
我是通过blur事件来触发的，隐藏和显示div达到这个效果，下面发一些判断的正则。<br />
判断电话号码，手机，座机一起判断的</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">11</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">|</span>^<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">|</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>\d<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>$<span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>判断邮编</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#125;</span>$</pre></td></tr></table></div>

<p>判断邮箱</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#91;</span>_<span style="color: #339933;">|</span>\_<span style="color: #339933;">|</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#93;</span>?<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+@</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#91;</span>_<span style="color: #339933;">|</span>\_<span style="color: #339933;">|</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#93;</span>?<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span>$</pre></td></tr></table></div>

<p>详细的js和phtml我就不说明了，js写的有点烂，放个链接，有兴趣的可以看下<br />
<a target="_blank" title="magento验证" href="http://www.magentofront-end.com/yanzheng/yanzheng.js">JQUERY</a>，<a target="_blank" title="magento验证" href="http://www.magentofront-end.com/yanzheng/register.text">PHTML</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/282/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento在产品页添加SKU，产品属性</title>
		<link>http://www.magentofront-end.com/magentomuban/270</link>
		<comments>http://www.magentofront-end.com/magentomuban/270#comments</comments>
		<pubDate>Mon, 01 Nov 2010 09:17:13 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[magento sku]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=270</guid>
		<description><![CDATA[Magento产品页有时需要把SKU号调出来，方法： 1 &#60;?php echo $this-&#62;htmlEscape&#40;$_product-&#62;getSku&#40;&#41;&#41; ?&#62; Magento的产品属性，在catalog.xml中已经写进去了。你可以在product view中找到 1 2 3 &#60;block type=&#34;catalog/product_view_attributes&#34; name=&#34;product.attributes&#34; as=&#34;additional&#34; template=&#34;catalog/product/view/attributes.phtml&#34;&#62; &#60;action method=&#34;addToParentGroup&#34;&#62;&#60;group&#62;detailed_info&#60;/group&#62;&#60;/action&#62; &#60;/block&#62; 现在只要在产品详细页（view.phtml）中想要的位置插入 1 &#60;?php echo $this-&#62;getChildHtml&#40;'additional'&#41; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>Magento产品页有时需要把SKU号调出来，方法：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">htmlEscape</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSku</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Magento的产品属性，在catalog.xml中已经写进去了。你可以在product view中找到</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>block type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;catalog/product_view_attributes&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;product.attributes&quot;</span> <span style="color: #b1b100;">as</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;additional&quot;</span> template<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;catalog/product/view/attributes.phtml&quot;</span><span style="color: #339933;">&gt;</span>
        <span style="color: #339933;">&lt;</span>action method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;addToParentGroup&quot;</span><span style="color: #339933;">&gt;&lt;</span>group<span style="color: #339933;">&gt;</span>detailed_info<span style="color: #339933;">&lt;/</span>group<span style="color: #339933;">&gt;&lt;/</span>action<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>block<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>现在只要在产品详细页（view.phtml）中想要的位置插入</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getChildHtml</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'additional'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/270/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magento速度优化——异步加载</title>
		<link>http://www.magentofront-end.com/magentomuban/266</link>
		<comments>http://www.magentofront-end.com/magentomuban/266#comments</comments>
		<pubDate>Fri, 29 Oct 2010 15:23:32 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento加速]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=266</guid>
		<description><![CDATA[Magento的这个速度优化，之前有讲到过了Magento加速利器——lazyload，其实就是异步加载。这次我讲的是在protype下的lazyload，效果是和淘宝的一样，不过淘宝用的是YUI的。不想加载jQUery的可以用这个protype下的lazyload，同样是减少http请求，但是他会先遍历一遍所有的预选的img类型。我就不详细解释了，我直接放js地址了http://www.bram.us/projects/js_bramus/lazierload/ Magento的加速要一点一点的坐上去， 最近为magento的速度事情纠结了很久。希望大家对于magento的速度优化有什么妙招，可以告诉我，嘿嘿]]></description>
			<content:encoded><![CDATA[<p>Magento的这个速度优化，之前有讲到过了<a href="../magentomuban/232">Magento加速利器——lazyload</a>，其实就是异步加载。这次我讲的是在protype下的lazyload，效果是和淘宝的一样，不过淘宝用的是YUI的。不想加载jQUery的可以用这个protype下的lazyload，同样是减少http请求，但是他会先遍历一遍所有的预选的img类型。我就不详细解释了，我直接放js地址了http://www.bram.us/projects/js_bramus/lazierload/</p>
<p>Magento的加速要一点一点的坐上去， 最近为magento的速度事情纠结了很久。希望大家对于magento的速度优化有什么妙招，可以告诉我，嘿嘿</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/266/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento进入插件管理报错解决方法</title>
		<link>http://www.magentofront-end.com/magentomuban/262</link>
		<comments>http://www.magentofront-end.com/magentomuban/262#comments</comments>
		<pubDate>Thu, 28 Oct 2010 06:35:21 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento插件]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=262</guid>
		<description><![CDATA[今天在安装magento插件的时候碰到的问题，报错信息是： Fatal error: require_once() [function.require]: Failed opening required &#8216;System.php&#8217;。这个是因为后台编译打开的原因，关掉即可。 另外还碰到个下载插件后无效的解决方法（仅限于转移服务器后），进入magento文件夹downloader\pearlib，里面有个pear.ini，删除就可以了。把安装无效的那个插件卸载了重新安装就可以了。 以上是水水友情协助，并强迫我给他的magento博客加链接http://blog.csdn.net/shuishui8310，强大的博客啊 ，可惜被百度惩罚了。magento开发人员去那寻宝吧。]]></description>
			<content:encoded><![CDATA[<p>今天在安装magento插件的时候碰到的问题，报错信息是：<br />
<strong>Fatal error</strong>:  require_once() [<a href="http://127.0.0.1/veken/index.php/SBkm46Vi/extensions_local/index/key/581fb43eae1a8b503a677d4a5af45a62/function.require">function.require</a>]: Failed opening required &#8216;System.php&#8217;。这个是因为后台编译打开的原因，关掉即可。</p>
<p>另外还碰到个下载插件后无效的解决方法（仅限于转移服务器后），进入magento文件夹downloader\pearlib，里面有个pear.ini，删除就可以了。把安装无效的那个插件卸载了重新安装就可以了。</p>
<p>以上是水水友情协助，并强迫我给他的magento博客加链接http://blog.csdn.net/shuishui8310，强大的博客啊 ，可惜被百度惩罚了。magento开发人员去那寻宝吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/262/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magneto功能强大的分页</title>
		<link>http://www.magentofront-end.com/magentomuban/258</link>
		<comments>http://www.magentofront-end.com/magentomuban/258#comments</comments>
		<pubDate>Wed, 20 Oct 2010 04:06:07 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento分页]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=258</guid>
		<description><![CDATA[Magento分页功能基本包含了常用的分页功能。之前没有去挖掘分页的功能，以为只有默认的一种，还在纠结默认的太简单了，准备换个。水水最近研究了下那东西，我就直接把他的劳动成果拿出来分享了，嘿嘿…… 这里只是简单的介绍下，让大家知道有这个功能，配置什么的都很简单。进入magento后台system-&#62;Configuration-&#62;Design有个Pagination栏，设置都在里面了，可以实现一般的分页功能了。有需要的可以慢慢玩了，如果有更好的，希望大家推荐下。]]></description>
			<content:encoded><![CDATA[<p><a title="Magento分页" href="http://www.magentofront-end.com/">Magento分页</a>功能基本包含了常用的分页功能。之前没有去挖掘分页的功能，以为只有默认的一种，还在纠结默认的太简单了，准备换个。水水最近研究了下那东西，我就直接把他的劳动成果拿出来分享了，嘿嘿……</p>
<p>这里只是简单的介绍下，让大家知道有这个功能，配置什么的都很简单。进入magento后台system-&gt;Configuration-&gt;Design有个Pagination栏，设置都在里面了，可以实现一般的分页功能了。有需要的可以慢慢玩了，如果有更好的，希望大家推荐下。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/258/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>去掉链接、按钮的虚框</title>
		<link>http://www.magentofront-end.com/magentomuban/255</link>
		<comments>http://www.magentofront-end.com/magentomuban/255#comments</comments>
		<pubDate>Thu, 14 Oct 2010 07:02:19 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[前端相关]]></category>
		<category><![CDATA[前端开发]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=255</guid>
		<description><![CDATA[链接和按钮在点击的时候会默认出现虚框，有时候因为美观我们需要去掉，最近就被这个小折腾了下，总结了下往上发的一些方法。 1、a{outline:none} 这个是针对Firefox的，但是IE下无效。 2、jQuery(&#8220;a&#8221;).each(function(){this.onmouseup = this.blur();})如果网站中已经加入jQuery，可以用这个方法。 3、< a href="#" hidefocus="true">……，在a标签中加入hidefocus=&#8221;true&#8221;，这个在IE下可用，但是通不过W3C验证。 4、< input type="button" border=0 onFocus="this.blur()" name="……"> button按钮标签中加入onFocus=&#8221;this.blur()&#8221;，这个同样无法通过w3c验证。 5、input{blr:expression(this.onFocus=this.blur());}给按钮加入这个样式，往上评论说这个东西不能多用，会影响性能，我也没验证，我只在一个地方用到。 上面的方法都可行，在使用时须看实际情况针对使用。]]></description>
			<content:encoded><![CDATA[<p>链接和按钮在点击的时候会默认出现虚框，有时候因为美观我们需要去掉，最近就被这个小折腾了下，总结了下往上发的一些方法。<br />
1、a{outline:none} 这个是针对Firefox的，但是IE下无效。<br />
2、jQuery(&#8220;a&#8221;).each(function(){this.onmouseup = this.blur();})如果网站中已经加入jQuery，可以用这个方法。<br />
3、< a href="#" hidefocus="true">……</ a>，在a标签中加入hidefocus=&#8221;true&#8221;，这个在IE下可用，但是通不过W3C验证。<br />
4、< input type="button" border=0 onFocus="this.blur()" name="……"> button按钮标签中加入onFocus=&#8221;this.blur()&#8221;，这个同样无法通过w3c验证。<br />
5、input{blr:expression(this.onFocus=this.blur());}给按钮加入这个样式，往上评论说这个东西不能多用，会影响性能，我也没验证，我只在一个地方用到。<br />
上面的方法都可行，在使用时须看实际情况针对使用。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/255/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento获取分类的销售排行</title>
		<link>http://www.magentofront-end.com/magentomuban/247</link>
		<comments>http://www.magentofront-end.com/magentomuban/247#comments</comments>
		<pubDate>Thu, 14 Oct 2010 06:48:09 +0000</pubDate>
		<dc:creator>紫月蓝骋</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[热门商品]]></category>

		<guid isPermaLink="false">http://www.magentofront-end.com/?p=247</guid>
		<description><![CDATA[Magento有个热门商品的插件，但是那个插件不显示产品的销售数量，现在分享下能够指定分类，显示销售数量的方法。 新建一个block，内容： 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 $totalPerPage = &#40;$this-&#62;show_total&#41; ? $this-&#62;show_total : 8; $counter = [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Magento" href="http://www.magentofront-end.com/"><strong>Magento</strong></a>有个热门商品的插件，但是那个插件不显示产品的销售数量，现在分享下能够指定分类，显示销售数量的方法。<br />
新建一个block，内容：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$totalPerPage <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>$this<span style="color: #339933;">-&gt;</span>show_total<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> $this<span style="color: #339933;">-&gt;</span>show_total <span style="color: #339933;">:</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">;</span>
$counter <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
$catalogid <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span>getSingleton<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'catalog/layer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>getCurrentCategory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$catalogid<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>$catalogid<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> $catalogid <span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
&nbsp;
$_featcategory <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span>getModel<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'catalog/category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>load<span style="color: #009900;">&#40;</span>$catalogid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
$visibility <span style="color: #339933;">=</span> array<span style="color: #009900;">&#40;</span>
                      Mage_Catalog_Model_Product_Visibility<span style="color: #339933;">::</span>VISIBILITY_BOTH<span style="color: #339933;">,</span>
                      Mage_Catalog_Model_Product_Visibility<span style="color: #339933;">::</span>VISIBILITY_IN_CATALOG
                  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$storeId <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span>app<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>getStore<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$_productCollection <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span>getResourceModel<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'reports/product_collection'</span><span style="color: #009900;">&#41;</span>
                              <span style="color: #339933;">-&gt;</span>addAttributeToSelect<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'*'</span><span style="color: #009900;">&#41;</span>
                              <span style="color: #339933;">-&gt;</span>addOrderedQty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
                              <span style="color: #339933;">-&gt;</span>addAttributeToFilter<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'visibility'</span><span style="color: #339933;">,</span> $visibility<span style="color: #009900;">&#41;</span>
                              <span style="color: #339933;">-&gt;</span>addCategoryFilter<span style="color: #009900;">&#40;</span>$_featcategory<span style="color: #009900;">&#41;</span>   <span style="color: #006600; font-style: italic;">//全部产品的排行</span>
                              <span style="color: #339933;">-&gt;</span>setOrder<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ordered_qty'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'desc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">?&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;?</span>php foreach<span style="color: #009900;">&#40;</span>$_productCollection <span style="color: #000066; font-weight: bold;">as</span> $product<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #339933;">?&gt;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&lt;?</span>php <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$counter <span style="color: #339933;">&lt;=</span> $totalPerPage<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #339933;">?&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;?</span>php $productUrl <span style="color: #339933;">=</span>  $product<span style="color: #339933;">-&gt;</span>getProductUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?&gt;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&lt;</span>li <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;l&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;this.target='_blank'&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;hotimg&quot;</span> href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;?php echo $productUrl ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;View &lt;?php echo $product-&gt;name ?&gt;&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;?php echo $this-&gt;helper('catalog/image')-&gt;init($product, 'image')-&gt;resize(77); ?&gt;&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;?php echo $product-&gt;name ?&gt;&quot;</span>  <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;&lt;</span>a onclick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;this.target='_blank'&quot;</span> href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;?php echo $productUrl ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;View &lt;?php echo $product-&gt;name  ?&gt;&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;?</span>php echo Mage<span style="color: #339933;">::</span>helper<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;core/string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>truncate<span style="color: #009900;">&#40;</span>$product<span style="color: #339933;">-&gt;</span>name<span style="color: #339933;">,</span><span style="color: #CC0000;">6</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;?&gt;</span>
<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
 <span style="color: #339933;">&lt;</span>span <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;price-label&quot;</span><span style="color: #339933;">&gt;&lt;?</span>php echo $this<span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Special Price:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>span <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;bestprice&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;?</span>php echo $this<span style="color: #339933;">-&gt;</span>helper<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'core'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>currency<span style="color: #009900;">&#40;</span>$product<span style="color: #339933;">-&gt;</span>getFinalPrice<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>span <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;selled&quot;</span><span style="color: #339933;">&gt;</span>已售出<span style="color: #339933;">:</span> <span style="color: #339933;">&lt;?</span>php echo <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span>$product<span style="color: #339933;">-&gt;</span>ordered_qty <span style="color: #339933;">?&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;?</span>php endif<span style="color: #339933;">;</span> $counter<span style="color: #339933;">++;</span> <span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;?</span>php endforeach<span style="color: #339933;">;</span> <span style="color: #339933;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>然后在magento中需要的地方插入即可，这个我在一个商城中已经用上，没有问题。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentofront-end.com/magentomuban/247/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

