重写 fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr 重写了Attr 文件但是不生效

问题咨询 · yue909 · 于 5年前 发布 · 1507 次阅读

在 appadmin\config\Yiiwritemap.php 内添加了

"\fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr" => "\appadmin\local\local_modules\Catalog\block\productinfo\index\Attr",

创建了 appadmin\local\local_modules\Catalog\block\productinfo\index\Attr.php 文件

namespace appadmin\local\local_modules\Catalog\block\productinfo\index;

use fec\helpers\CRequest;
//use fecshop\app\appadmin\modules\Catalog\helper\Product as ProductHelper;
use Yii;

class Attr extends fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr
{
	 public function getPriceInfo(){
		return 1;
	}
}

重写没生效 ,怎么破?

共收到 6 条回复
Fecmall#15年前 0 个赞

1.文档: http://www.fecshop.com/doc/fecshop-guide/develop/cn-1.0/guide-fecshop-rewrite-func.html#8rewritemapblock-model

2.

class Attr extends fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr
{
	 public function getPriceInfo(){
		return 1;
	}
}

改成

class Attr extends \fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr
{
	 public function getPriceInfo(){
		return 1;
	}
}
yue909#25年前 0 个赞

@Fecshop #1楼 修改了,还是不行 ,不知哪里出问题了

Fecmall#45年前 0 个赞

appadmin\config\Yiiwritemap.php

"\fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr" => "\appadmin\local\local_modules\Catalog\block\productinfo\index\Attr",

修改: 改成

'\fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr' => '\appadmin\local\local_modules\Catalog\block\productinfo\index\Attr',

或者

"\\fecshop\\app\\appadmin\\modules\\Catalog\\block\\productinfo\\index\\Attr" => "\\appadmin\\local\\local_modules\\Catalog\\block\\productinfo\\index\\Attr",

这是一个低级错误!

yue909#55年前 0 个赞

@Fecshop #4楼 原来如此,单引号就行了,还的多研究研究, 感谢大佬

Fecmall#65年前 0 个赞

@yue909 #5楼

\ 是转移字符,在双引号里面得用 \ ,因为双引号里面会转义, 譬如双引号里面的 \n代表回车

单引号里面不会转义

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics