prestashop 1.4.4的lighttpd rewrite规则

No Comments

由于prestashop 1.4.3更新了一个新的“文件系统”,将图片文件分文件夹存放,为了同时兼容两种的文件存放方式,需要更改重写规则

url.rewrite-once = (
	"^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$" => "/img/p/$1-$2$3.jpg",
	"^/([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1-$2.jpg",
	"^/([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$1$2.jpg",
	"^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$1$2$3.jpg",
	"^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$1$2$3$4.jpg",
	"^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg",
	"^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg",
	"^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg",
	"^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg",
	"^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*\.jpg$" => "/img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg",
 
 
	"^/([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$" => "/img/c/$1$2.jpg",
	"^/lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" => "/product.php?id_product=$3&isolang;=$1$6" ,
	"^/lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" =>"/product.php?id_product=$2&isolang;=$1&$4",
 
	"^/lang-([a-z]{2})/content/category/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?"  =>"/cms.php?id_cms_category=$2&isolang;=$1&$5" ,
 
	"^/lang-([a-z]{2})/content/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms=$2&isolang;=$1&$4",
	"^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" => "/product.php?id_product=$2&$5" ,
	"^/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" =>"/product.php?id_product=$1&$4",
	"^/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/category.php?id_category=$1&$4" ,
	"^/lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/category.php?id_category=$2&isolang;=$1&$5" ,
 
	"^/content/category/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms_category=$1" ,
 
	"^/content/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms=$1&$4" ,
	"^/([0-9]+)__([a-zA-Z0-9-]*)(\?(.*))?" =>"/supplier.php?id_supplier=$1&$4" ,
	"^/([0-9]+)_([a-zA-Z0-9-]*)(\?(.*))?" =>"/manufacturer.php?id_manufacturer=$1&$4",
	"^/lang-([a-z]{2})/(\?(.*))?" => "/index.php?isolang=$1&$2",
	"^/address(\?(.*))?" => "/address.php$1",
	"^/addresses(\?(.*))?" => "/addresses.php$1",
	"^/authentication(\?(.*))?" => "/authentication.php$1",
	"^/cart(\.php)?(\?(.*))?" => "/cart.php$2",
	"^/discount(\?(.*))?" => "/discount.php$1",
	"^/guest-tracking(\?(.*))?" => "/guest-tracking.php$1",
	"^/order-history(\?(.*))?" => "/history.php$1",
	"^/identity(\?(.*))?" => "/identity.php$1",
	"^/my-account(\?(.*))?" => "/my-account.php$1",
	"^/order(\?(.*))?" => "/order.php$1",
	"^/order-follow(\?(.*))?" => "/order-follow.php$1",
	"^/quick-order(\?(.*))?" => "/order-opc.php$1",
	"^/password-recovery(\?(.*))?" => "/password.php$1",
	"^/order-slip(\?(.*))?" => "/order-slip.php$1",
	"^/search(\?(.*))?" => "/search.php$1",
	"^/contact-us(\?(.*))?" => "/contact-form.php$1",
	"^/new-products(\?(.*))?" => "/new-products.php$1",
	"^/page-not-found(\?(.*))?" => "/404.php$1",
	"^/sitemap$" => "/sitemap.php$1",
	"^/best-sales(\?(.*))?" => "/best-sales.php$1",
	"^/prices-drop(\?(.*))?" => "/prices-drop.php$1",
	"^/stores(\?(.*))?" => "/stores.php$1"
 
)

OMG,升级到prestashop1.4.2.5后不能填写地址了

No Comments

从1.4.0或以前版本升级到1.4.2.5最新版本后,发现单步支付中不能填写地址了,没有地址,国家等选项了。

这是因为prestashop 1.4.2.5新增加了针对国家的“地址格式”功能,升级的时候”ps_address_format”表为空没有任何地址造成的。

解决办法,打开Back Office 》 Shipping 》 Countries,找到你的默认国家,修改。

点击Use a default layout,或者选择需要的模板。

dreamweaver cs5 正则替换prestashop google base feed

No Comments

应用情景:

打开了一个prestashop的google base feed,想要去提交给W3C Link Checker来验证。

解决方式:

用dreamweaver打开feed xml文件。

使用

</link>([\s\S]+?)<link>替换为\r\n

来去除大部分的xml。

再把头部和尾部的xml删除。

使用

(http(.+?)\.html)+ 替换为 <a href=”$1″>$1</a>

来把网址变成链接

最后,保存为html文件传到服务器上,就可以使用w3c link checker服务了。

prestashop 1.4问题修改:sitemap

2 Comments

1.2中sitemap就有问题,1.4依然有问题,只不过问题不同了而已。

bug:

如果你只有一种语言,生成的sitemap中的首页后还是有语言的地址,这样给google看到的结果就是首页是404。
例如http://www.yourdomin.com/en/

解决:

修改moudles/gsitemap/gsitemap.php第92行,由原来的

if (Configuration::get('PS_REWRITING_SETTINGS'))

改为

if (Configuration::get('PS_REWRITING_SETTINGS') && count($langs) > 1)

也放了修改好的上来gsitemap bug 1.4.0.7 (206)

prestashop 1.4问题修改:PayPal不允许从您所居住的国家或地区运送到您指定为目的地的国家或地区

5 Comments

PayPal不允许从您所居住的国家或地区运送到您指定为目的地的国家或地区,英文是Paypal does not allow your country of residence to ship to the country you wish to。
是由于prestashop 1.4的新paypal模块自动设置了address_override选项。把modules/paypal/redirect.tpl的36行和35行改成

<input type="hidden" name="address_override" value="0" />

prestashop 1.4图片上传bug:Fatal error (StockMvt -> id_stock_mvt_reason = -1)

No Comments

这就是prestashop 1.4图片上传bug “Fatal error (StockMvt -> id_stock_mvt_reason = -1)”。bug反馈在http://forge.prestashop.com/browse/PSCFI-995。

解决方法是,打开ps_stock_mvt_reason表,取消主键id_stock_mvt_reason的auto increment,然后

UPDATE `ps_stock_mvt_reason` SET `id_stock_mvt_reason` = '0',
`sign` = '1' WHERE `ps_stock_mvt_reason`.`id_stock_mvt_reason` =4

如果改完发现问题如故,请打开/关闭缓存至少1次。

prestashop 1.4后台模块bug

2 Comments

有时候点击一个模块的配置,页面上会显示“Module uninstalled successfully”。这时候的模块一般显示已安装,但是如果去uninstall它,它又会显示模块没有安装。这个问题出现的原因还在研究,解决办法是:删除ps_modules表中对应的模块。

DELETE FROM `ps_module` WHERE `name` = '你的模块名称'

注意这里的模块名称是模块的class名称,不是显示在界面上的那个。比如是blockcategories而不是Categories block。配置等信息不会丢。

prestashop 1.4的lighttpd的rewrite规则

No Comments

根据默认的规则转换的,如果有不一样的地方,需要自己配置。

url.rewrite-once = (
	"^/([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$" => "/img/p/$1-$2$3.jpg",
	"^/([0-9]+)(\-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*)\.jpg$" => "/img/c/$1$2.jpg",
	"^/lang-([a-z]{2})/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" => "/product.php?id_product=$3&isolang;=$1$6" ,
	"^/lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" =>"/product.php?id_product=$2&isolang;=$1&$4",
	"^/lang-([a-z]{2})/content/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms=$2&isolang;=$1&$4",
 
	"^/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" => "/product.php?id_product=$2&$5" ,
	"^/([0-9]+)\-([a-zA-Z0-9-]*)\.html(\?(.*))?" =>"/product.php?id_product=$1&$4",
 
 
	"^/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/category.php?id_category=$1&$4" ,
	"^/lang-([a-z]{2})/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/category.php?id_category=$2&isolang;=$1&$5" ,
	"^/content/([0-9]+)\-([a-zA-Z0-9-]*)(\?(.*))?" =>"/cms.php?id_cms=$1&$4" ,
	"^/([0-9]+)__([a-zA-Z0-9-]*)(\?(.*))?" =>"/supplier.php?id_supplier=$1&$4" ,
	"^/([0-9]+)_([a-zA-Z0-9-]*)(\?(.*))?" =>"/manufacturer.php?id_manufacturer=$1&$4",
 
	"^/lang-([a-z]{2})/(\?(.*))?" => "/index.php?isolang=$1&$2",
 
	"^/address(\?(.*))?" => "/address.php$1",
	"^/addresses(\?(.*))?" => "/addresses.php$1",
	"^/authentication(\?(.*))?" => "/authentication.php$1",
	"^/cart(\?(.*))?" => "/cart.php$1",
	"^/discount(\?(.*))?" => "/discount.php$1",
	"^/guest-tracking(\?(.*))?" => "/guest-tracking.php$1",
	"^/order-history(\?(.*))?" => "/order-history.php$1",
	"^/identity(\?(.*))?" => "/identity.php$1",
	"^/my-account(\?(.*))?" => "/my-account.php$1",
	"^/order(\?(.*))?" => "/order.php$1",
	"^/order-follow(\?(.*))?" => "/order-follow.php$1",
	"^/quick-order(\?(.*))?" => "/order-opc.php$1",
	"^/password-recovery(\?(.*))?" => "/password.php$1",
	"^/order-slip(\?(.*))?" => "/order-slip.php$1",
	"^/search(\?(.*))?" => "/search.php$1",
	"^/contact-us(\?(.*))?" => "/contact-form.php$1",
	"^/new-products(\?(.*))?" => "/new-products.php$1",
	"^/page-not-found(\?(.*))?" => "/404.php$1",
	"^/sitemap$" => "/sitemap.php$1",
	"^/best-sales(\?(.*))?" => "/best-sales.php$1",
	"^/prices-drop(\?(.*))?" => "/prices-drop.php$1",
	"^/stores(\?(.*))?" => "/stores.php$1"
 
)

prestashop多页标题重复问题的修改

No Comments

这是对于prestashop seo方面的改动,在分类的第二页的标题和第一页是一样的,所以加了一个page 2这样的修改。
适用于prestashop 1.3.x版本。

$metaTags['meta_title'] = $defaultValue.' - '.(($_GET['p'] > 1) ? 'Page '.$_GET['p'] : '' ).' - '.Configuration::get('PS_SHOP_NAME');

在classes/tools.php 587行。

prestashop 1.4终极优化指南

1 Comment

加了终极2个字,是因为速度确实提升了400%。

		$rss_links = array();
		$cache = dirname(__FILE__).'/cache.serialize';
		if(file_exists($cache) && (time() - filemtime($cache)) < 5000)
			$contents = unserialize(file_get_contents($cache));
		else	
			$url && ($contents = @file_get_contents($url));
 
		if (@$src = new XML_Feed_Parser($contents)){
			file_put_contents($cache, serialize($contents));
			for ($i = 0; $i < ($nb ? $nb : 5); $i++)
				if (@$item = $src->getEntryByOffset($i))
					$rss_links[] = array('title' => $item->title, 'url' => $item->link);
		}

这条优化建议是针对所有版本的,并非只有prestashop1.4。这段代码用以替换module中的blockrss文件夹中的blockrss.php141行开始到// Display smarty结束的部分。加了一个rss的缓存而已,但是官方显然没注意到这个问题,这个模板已经很多个版本没有改过了。

未完待续

Older Entries