Fecmall

第 2 位会员

会员
个人信息
  • 加入于 2017-05-31 17:38:45
  • 城市 Qingdao
  • GitHub https://github.com/fecshop
  • 最后登录时间 10天前
  • 签名 净化自己,潜心编码
个人简介
Terry,Fecmall开源产品作者,12年电商经验一线程序员开发者,擅长规划产品,架构设计。
个人成就
  • 发表文章次数 744
  • 发布回复次数 5760
  • 个人主页浏览次数 683
/sbin/swapon /var/swap.1报错7年前

@bb2visit #3楼 用markdown 格式改改格式,参看 : http://www.fecshop.com/topic/624

第5部分,用代码块括起来。

模型Product文件$_customProductAttrs为什么定为成static,不定义static不是更好吗?7年前

@wooecshop #5楼 静态变量的好处,就是可以在任何地方初始化,只要一次就可以了, 因此可以在@app/appadmin/modules/Catalog/block/productinfo/index/Attr.php 里面调用Yii::$service->product->addGroupAttrs($this->_currentAttrGroup); 进行初始化

这块代码一年前写的,我也有点忘记的差不多了。

对于你说的,也是可以的,但是静态变量更灵活一点,执行一次,就像产品model的初始化一样

当执行 addCustomProductAttrs($attrs) , 代码如下:

/**
     * get custom product attrs.
     */
    public static function addCustomProductAttrs($attrs)
    {
        self::$_customProductAttrs = $attrs;
        // 设置为空后,在执行方法attributes()的时候,就会重新计算 $this->_product_attributes 的值
        $this->_product_attributes = [];
    }

会将 $this->_product_attributes 设置为空 , 执行方法attributes()的时候,就会重新计算 $this->_product_attributes 的值

模型Product文件$_customProductAttrs为什么定为成static,不定义static不是更好吗?7年前

加入类变量:$this->_product_attributes 保证 方法attributes()里面的内容只会执行一次,后面的都是从类变量:$this->_product_attributes中取值,这样,后面更改 self::$_customProductAttrs 就没有干扰了。

模型Product文件$_customProductAttrs为什么定为成static,不定义static不是更好吗?7年前

目前不能改成类对象,改动后,会引发大面积的报错,原因如下:

在 @app/appadmin/modules/Catalog/block/productinfo/Manageredit.php

public function getBaseInfo()
    {
        $this->_lang_attr = '';
        $this->_textareas = '';
        $editArr = $this->_attr->getBaseInfo();
        $editBar = $this->getEditBar($editArr);

        return $this->_lang_attr.$editBar.$this->_textareas;
    }

执行后,会调用:@app/appadmin/modules/Catalog/block/productinfo/index/Attr.php

public function __construct($one)

    {
        /**
         * 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
         */
        list($this->_productHelperName,$this->_productHelper) = Yii::mapGet($this->_productHelperName);  
        
        $currentAttrGroup = CRequest::param('attr_group');
        if ($currentAttrGroup) {
            $this->_currentAttrGroup = $currentAttrGroup;
        } elseif (isset($one['attr_group']) && $one['attr_group']) {
            $this->_currentAttrGroup = $one['attr_group'];
        } else {
            $this->_currentAttrGroup = Yii::$service->product->getDefaultAttrGroup();
        }

        Yii::$service->product->addGroupAttrs($this->_currentAttrGroup);
    }

执行 Yii::$service->product->addGroupAttrs($this->_currentAttrGroup); 就会执行

public function addGroupAttrs($attr_group)
    {
        $attrInfo = Yii::$service->product->getGroupAttrInfo($attr_group);
        if (is_array($attrInfo) && !empty($attrInfo)) {
            $attrs = array_keys($attrInfo);
            $this->_productModel->addCustomProductAttrs($attrs);
        }
    }

更改静态变量,这样初始化一次,在产品页面的各个地方引用product,就会把属性组的属性加上去

因此不能按照你的方式更改

对于上面出现的问题,可以这样优化解决:

protected $_product_attributes;
public function attributes()
    {
        if (!$this->_product_attributes) {
            $origin = [
                '_id',
                'name',
                'spu',
               
			    ...
				
            ];
            if (is_array(self::$_customProductAttrs) && !empty(self::$_customProductAttrs)) {
                $origin = array_merge($origin, self::$_customProductAttrs);
            }
            $this->_product_attributes = $origin;
        }

        return $this->_product_attributes;
    }

文件更改为:https://github.com/fecshop/yii2_fecshop/blob/master/models/mongodb/Product.php

模型Product文件$_customProductAttrs为什么定为成static,不定义static不是更好吗?7年前

本身就是技术交流

1.fecshop肯定存在很多的不妥之处,除了一些xxx拿后台界面说事外(本人早就声明,前端不是长项,这些人还一个劲的拿界面说事,标榜为了xx好,如果为了fecshop好,你到是来贡献啊,喊的人多,没一个参与去优化后台界面的),其他的都欢迎来稿

2.细致看了一下代码和你的回复,你说的是对的,虽然目前这种方式不会造成问题,但是有隐患

譬如:如果产品批量处理,这些产品是不同的属性组,遍历处理产品前,需要重新设置更改静态变量:$_customProductAttrs, 每次改动,会将前面new出来的product model对象的 attributes()的值进行了更改

3.更改一下这里的代码, 多谢你的建议,感谢!

模型Product文件$_customProductAttrs为什么定为成static,不定义static不是更好吗?7年前

OK,说出你的论点的同时,请说出你的论据!

论点:把属性$_customProductAttrs 定为成static,不用定义成static 不也是更好吗?

论据:??

/sbin/swapon /var/swap.1报错7年前

原因就是你的内存太小,需要swap搞虚拟内存,其他的参考资料:

https://shipengliang.com/software-exp/swapon-failed-operation-not-permitted-解决办法.html

http://blog.gt520.com/vps/91.html

资料大把。

/sbin/swapon /var/swap.1报错7年前

搜索一下就能解决这个报错,这些报错和fecshop没有关系

https://www.njphper.com/detail/158.html

在安装phalcon的时候遇到内存不足的问题,需要swap增加内存,可是在docker里面遇到 swapon failed: Operation not permitted

Hi, As each running docker container uses the host Kernel, they also use the memory and swap of the host. If this is a one of requirement its better to increase the host swap space.

If you want to still add swap from the container you have two options.

Run container in privileged mode

In this case you will have to run the container with --privileged option.

Example

docker run -it --rm --privileged centos:6

Running container with privileged mode gives container full privilege on the host. If you read the manpage of swapon you can see that for swapon to run the process should have CAP_SYS_ADMIN capability. In Docker you can add a particular capability selectively to the container using the --cap-add argument.

Example

docker run -it --rm --cap-add SYS_ADMIN centos:6

If you run the container in either of the above two modes you can achieve what you are trying.

Now the problem with this approach is , when you create swap inside the container and start using that, its actually the Host Kernel that is using it, as a result when you exit the container without a swapoff the host kernel will be still using the file, and you wont get a clean exit of the container. You will see a dead status for the container.

翻译:

嗨, 由于每个运行的docker容器都使用主机内核,它们还使用主机的内存和交换。如果这是要求更好的增加主机交换空间的一个。 如果你想从容器中添加交换,你有两个选择。 以特权模式运行容器 在这种情况下,您将必须使用--privileged选项运行容器。

示例

docker run -it --rm --privileged centos:6

运行具有特权模式的容器可以为主机提供容器完整权限。如果您阅读swapon的联机帮助页面,您可以看到,对于swapon来运行该进程应该具有CAP_SYS_ADMIN功能。在Docker中,您可以使用-cap-add参数有选择地向容器添加特定的功能。

示例

docker run -it --rm --cap-add SYS_ADMIN centos:6

如果您以上述两种模式运行容器,您可以实现您正在尝试的功能。

现在,这种方法的问题是,当您在容器内创建交换并开始使用它时,实际上是使用它的主机内核,因此当您退出容器而不进行swapoff时,主机内核将仍然使用该文件,你不会得到一个干净的出口的容器。您将看到容器的死亡状态。

关于YiiRewriteMap重写block的问题7年前

周末会发一个子版本。

关于YiiRewriteMap重写block的问题7年前

这个一个bug

对于controller中直接调用的block,是可以重写的

而对于view中的index.php文件中使用下面的方式:

<div class="product_custom_options">
    <?php # custom options部分
        $optionsView = [
            'class' =>  'fecshop\app\appfront\modules\Catalog\block\product\CustomOption',
            'view'	=> 'catalog/product/index/custom_option.php',
            'custom_option' 	=> $custom_option,
            'attr_group'		=> $attr_group,
            'product_id'		=> $_id ,
            'middle_img_width' 	=> $media_size['middle_img_width'],
        ];
        $optionsParam = [
            
        ];
        
        
    ?>
    <?= Yii::$service->page->widget->render($optionsView,$optionsParam); ?>

</div>

则不会重写,这是一个bug,已经修复:https://github.com/fecshop/yii2_fecshop/commit/73ed48597de7af2c27b09b7d3a2120b9e51cc717

service log 开启后报错7年前

本周末,看看发布一个子版本。

service log 开启后报错7年前

您好,这的确是一个bug,之前做完后,其他功能进行了调整,而没有关注这个偏底层的service log

现在已经修复,并进行了一系列的调整。

代码提交:https://github.com/fecshop/yii2_fecshop/commit/e7321ab2a250a45496e7e7b494bd07c72cc2e932

文档说明:http://www.fecshop.com/doc/fecshop-guide/develop/cn-1.0/guide-fecshop-service-log.html

启动docker ,下载安装fecshop出错7年前

要么你就先用百度网盘的地址, https://github.com/fecshop/yii2_fecshop_docker
往下看,会看到百度网盘的地址,里面是完整文件压缩包

启动docker ,下载安装fecshop出错7年前

php_network_getaddresses: getaddrinfo failed: Name or service not known https://packagist.phpcomposer.com could not be fully loaded

你用的是composer的中国镜像把? 不知道是不是中国镜像挂了,还是怎么情况,

你可以切换成国外镜像试试:

http://www.fancyecommerce.com/2017/04/19/composer-默认地址改为中国镜像地址,以及中国镜像地址/

启动docker ,下载安装fecshop出错7年前

你的报错是:

php_network_getaddresses: getaddrinfo failed

百度搜搜:https://blog.csdn.net/ownfire/article/details/7850890

网络加载问题。

关于YiiRewriteMap重写block的问题7年前

把文件路径(文件结构树)抓图贴一下。(你先贴一下截图,晚上我测试看看)

关于YiiRewriteMap重写block的问题7年前

姿势不对,估计是大小写,或者哪里存在空格等,不易发现的小问题导致的。

仔细找找

产品添加Add to Favorites 失败。7年前

造成这个问题的原因已经找到,详细参看帖子: http://www.fecshop.com/topic/847

Your Site Analytics