关于商品属性限制

问题咨询 · xiaoming · 于 5年前 发布 · 2109 次阅读

修改了商品属性,因为有个尺寸的属性例如 (1.2x2.3)需要有特殊字符 . ,想请问下这里为什么要做这些字符串的限制呢,如果我把这个限制删了会出现什么问题呢?

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

因为分类侧栏要使用这些属性做属性过滤,选择的属性是通过url get param传递的

而url中对参数的字符是有限制的,因此,对于属性的字符也进行了限制。只能使用里面的相应字符。

xiaoming#25年前 0 个赞
/**
     * @property $strVal | String
     * 把属性值转换成url格式的字符串,用于生成url.
     */
    protected function actionAttrValConvertUrlStr($strVal)
    {
        if ($strVal) {
            // if (!preg_match('/^[A-Za-z0-9-_ &]+$/', $strVal)) {
            //     throw new InvalidValueException('"'.$strVal .'":contain special str , you can only contain special string [A-Za-z0-9-_ &]');
            // }
            $strVal = urlencode($strVal);
            $convert = $this->strUrlRelation();
            foreach ($convert as $originStr => $nStr) {
                $strVal = str_replace($originStr, $nStr, $strVal);
            }

            return $strVal;
        }
    }

如果我把这个函数重写成这样,就是不作判断直接用url转义应该不会出现什么问题吧,怕其他方面会出问题

Fecmall#35年前 0 个赞

@xiaoming #2楼 你测试下试试吧,主要看分类侧栏属性过滤是否会出问题。

xiaoming#45年前 0 个赞

@Fecshop #3楼 要是只是侧栏使用到的话暂时没有想到会有什么问题出现 ,应该没什么问题 ,简单测试了一下可以的

Fecmall#55年前 0 个赞

嗯,多测试看看

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