wooecshop

第 242 位会员

会员
个人信息
  • 加入于 2017-11-13 20:52:52
  • 城市 南京
  • 最后登录时间 5天前
个人简介
https://robomongo.org/
个人成就
  • 发表文章次数 6
  • 发布回复次数 14
  • 个人主页浏览次数 11
模型Product文件$_customProductAttrs为什么定为成static,不定义static不是更好吗?8个月前

@Fecshop #4楼 谢谢解答,我好好理解下,代码量太大,我并没完全看完

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

static变量对于类型是全局的,如果我新增了一个新产品,然后添加了对应的产品组,后面我又新增一产品,新品组默认不就是上次的了所选的产品组了吗?我知道后台有选择产品组的功能。而且查询是也会保留次赋值变量$_customProductAttrs的值吗?

纯属交流,并不是说fecshop不好。

/**
     * @property $attr_group | String , 属性组名称
     * 给product model 增加相应的属性组对应的属性。
     */
    protected function actionAddGroupAttrs($attr_group)
    {
        return $this->_product->addGroupAttrs($attr_group);
    }
优惠券使用条件问题1年前

是我看错了

fecshop在windows下安装1年前

@learence #4楼 执行:php init 或者 init 都可以,执行init,实际上执行执行是init.bat,winidows下面不需要加"./"。

windows下,网站根目录下1年前

是PHP安装的目录,比如:D:\www\phpstudy\php555 ,不是文件

windows下,网站根目录下1年前

yii.bat文件不要修改,需要把php的bin目录添加到系统环境变量

windows下,网站根目录下1年前

看看php.exe 有没有加到windows环境变量中,单独执行php -v,看看有没有输出php版本信息

fecshop在windows下安装1年前

@Terry #1楼 不过我也初学者,开发环境搭好了学习才刚刚开始。

Object configuration must be an array containing a "class" element.错误是怎么回事1年前

我写了5,6年程序,都一直是c/c++。初次接触电商。感谢大神 @Terry 耐心帮助!

Object configuration must be an array containing a "class" element.错误是怎么回事1年前

我什么也没有修改。

yii\base\InvalidConfigException: Object configuration must be an array containing a "class" element. in D:\wamp\www\wordpress\vendor\yiisoft\yii2\BaseYii.php:353 Stack trace: #0 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Application.php(49): yii\BaseYii::createObject(Array) #1 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Application.php(67): fecshop\services\Application->getChildService('image') #2 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\product\Image.php(69): fecshop\services\Application->get('image') #3 [internal function]: fecshop\services\product\Image->actionGetUrl('/default.jpg') #4 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Service.php(49): call_user_func_array(Array, Array) #5 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\product\Image.php(103): fecshop\services\Service->__call('getUrl', Array) #6 [internal function]: fecshop\services\product\Image->actionDefautImg() #7 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Service.php(49): call_user_func_array(Array, Array) #8 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\category\Product.php(90): fecshop\services\Service->call('defautImg', Array) #9 [internal function]: fecshop\services\category\Product->actionConvertToCategoryInfo(Array) #10 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Service.php(49): call_user_func_array(Array, Array) #11 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\block\home\Index.php(50): fecshop\services\Service->__call('convertToCatego...', Array) #12 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\block\home\Index.php(28): fecshop\app\appfront\modules\Cms\block\home\Index->getProductBySkus(Array) #13 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\block\home\Index.php(19): fecshop\app\appfront\modules\Cms\block\home\Index->getFeaturedProduct() #14 D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\controllers\HomeController.php(19): fecshop\app\appfront\modules\Cms\block\home\Index->getLastData() #15 [internal function]: fecshop\app\appfront\modules\Cms\controllers\HomeController->actionIndex() #16 D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array) #17 D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array) #18 D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Controller->runAction('index', Array) #19 D:\wamp\www\wordpress\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('cms/home/index', Array) #20 D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(fecshop\yii\web\Request)) #21 D:\wamp\www\wordpress\appfront\web\index.php(87): yii\base\Application->run() #22 {main} Copy Stacktrace Search Stackoverflow Search Google Exception Invalid Configuration – yii\base\InvalidConfigException

Object configuration must be an array containing a "class" element.

  1. in D:\wamp\www\wordpress\vendor\yiisoft\yii2\BaseYii.php at line 353 344345346347348349350351352353354355356357358359360361362 if (is_string($type)) {

         return static::$container->get($type, $params);
     } elseif (is_array($type) && isset($type['class'])) {
         $class = $type['class'];
         unset($type['class']);
         return static::$container->get($class, $params, $type);
     } elseif (is_callable($type, true)) {
         return static::$container->invoke($type, $params);
     } elseif (is_array($type)) {
         throw new InvalidConfigException('Object configuration must be an array containing a "class" element.');
     }
    
     throw new InvalidConfigException('Unsupported configuration type: ' . gettype($type));
    

    }

    private static $_logger;

    /**

    • @return Logger message logger
  2. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Application.php at line 49 – yii\BaseYii::createObject(['appbase' => ['appfront' => ['basedir' => '@appimage/appfront', 'basedomain' => '//img.appfront.fancyecommerce.co...'], 'apphtml5' => ['basedir' => '@appimage/apphtml5', 'basedomain' => '//img.apphtml5.fancyecommerce.co...'], 'appadmin' => ['basedir' => '@appimage/appadmin', 'basedomain' => 'http://img2.fecshoptest.com'], 'common' => ['basedir' => '@appimage/common', 'basedomain' => '//img.fancyecommerce.com']]]) 43444546474849505152535455
     if (!$this->_childService[$childServiceName]) {
         $childService = $this->childService;
         if (isset($childService[$childServiceName])) {
             $service = $childService[$childServiceName];
             if(!isset($service['enableService']) || $service['enableService']){
                 $this->_childService[$childServiceName] = Yii::createObject($service);
             }else{
                 throw new InvalidConfigException('Child Service ['.$childServiceName.'] is disable in '.get_called_class().', you must config it! ');
             }
         } else {
             throw new InvalidConfigException('Child Service ['.$childServiceName.'] is not find in '.get_called_class().', you must config it! ');
         }
    
  3. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Application.php at line 67 – fecshop\services\Application::getChildService('image') 616263646566676869 * @property $attr | String , service的name。
    • 魔术方法,当调用一个属性,对象不存在的时候就会执行该方法,然后
    • 根据构造方法注入的配置,实例化service对象。 */ public function __get($attr) { return $this->getChildService($attr); } }
  4. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\product\Image.php at line 69 – fecshop\services\Application::__get('image') 63646566676869707172737475 /**

    • 通过产品图片的相对路径得到产品图片的url. */ protected function actionGetUrl($str) { return Yii::$service->image->GetImgUrl($this->imageFloder.$str, 'common'); }

    /**

    • 通过产品图片的相对路径得到产品图片的绝对路径. */ protected function actionGetDir($str)
  5. fecshop\services\product\Image::actionGetUrl('/default.jpg')
  6. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Service.php at line 49 – call_user_func_array([fecshop\services\product\Image, 'actionGetUrl'], ['/default.jpg']) 43444546474849505152535455 } else {

         $method = 'action'.ucfirst($originMethod);
         $this->_callFuncLog[$originMethod] = $method;
     }
     if (method_exists($this, $method)) {
         $this->beginCall($originMethod, $arguments);
         $return = call_user_func_array([$this, $method], $arguments);
         $this->endCall($originMethod, $arguments);
    
         return $return;
     } else {
         throw new InvalidCallException('fecshop service method is not exit.  '.get_class($this)."::$method");
     }
    
  7. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\product\Image.php at line 103 – fecshop\services\Service::__call('getUrl', ['/default.jpg']) 979899100101102103104105106107108109 /**

    • 获取产品默认图片的完整URL */ protected function actionDefautImg() { if (!$this->_defaultImg) {

       $this->_defaultImg = $this->getUrl($this->defaultImg);
      

      }

      return $this->_defaultImg; }

    /**

  8. fecshop\services\product\Image::actionDefautImg()
  9. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Service.php at line 49 – call_user_func_array([fecshop\services\product\Image, 'actionDefautImg'], []) 43444546474849505152535455 } else {

         $method = 'action'.ucfirst($originMethod);
         $this->_callFuncLog[$originMethod] = $method;
     }
     if (method_exists($this, $method)) {
         $this->beginCall($originMethod, $arguments);
         $return = call_user_func_array([$this, $method], $arguments);
         $this->endCall($originMethod, $arguments);
    
         return $return;
     } else {
         throw new InvalidCallException('fecshop service method is not exit.  '.get_class($this)."::$method");
     }
    
  10. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\category\Product.php at line 90 – fecshop\services\Service::__call('defautImg', []) 84858687888990919293949596 /**
    • 将service取出来的数据,处理一下,然后前端显示。 */ protected function actionConvertToCategoryInfo($collection) { $arr = []; $defaultImg = Yii::$service->product->image->defautImg(); if (is_array($collection) && !empty($collection)) {
       foreach ($collection as $one) {
           if (is_array($one['name']) && !empty($one['name'])) {
               $name = Yii::$service->store->getStoreAttrVal($one['name'], 'name');
           } else {
               $name = $one['name'];
      
  11. fecshop\services\category\Product::actionConvertToCategoryInfo([])
  12. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\services\Service.php at line 49 – call_user_func_array([fecshop\services\category\Product, 'actionConvertToCategoryInfo'], [[]]) 43444546474849505152535455 } else {

        $method = 'action'.ucfirst($originMethod);
        $this->_callFuncLog[$originMethod] = $method;
    }
    if (method_exists($this, $method)) {
        $this->beginCall($originMethod, $arguments);
        $return = call_user_func_array([$this, $method], $arguments);
        $this->endCall($originMethod, $arguments);
    
        return $return;
    } else {
        throw new InvalidCallException('fecshop service method is not exit.  '.get_class($this)."::$method");
    }
    
  13. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\block\home\Index.php at line 50 – fecshop\services\Service::__call('convertToCategoryInfo', [[]]) 44454647484950515253545556 'special_from', 'special_to',

            'url_key', 'score',
        ];
        $filter['where'] = ['in', 'sku', $skus];
        $products = Yii::$service->product->getProducts($filter);
        //var_dump($products);
        $products = Yii::$service->category->product->convertToCategoryInfo($products);
    
        return $products;
    }
    

    }

    public function initHead()

  14. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\block\home\Index.php at line 28 – fecshop\app\appfront\modules\Cms\block\home\Index::getProductBySkus(['men0003', 'men0002', 'men0001', 'computer001-xinghao2-cpu3', ...]) 22232425262728293031323334 }

    public function getFeaturedProduct() {

    $featured_skus = Yii::$app->controller->module->params['homeFeaturedSku'];
    
    return $this->getProductBySkus($featured_skus);
    

    }

    public function getBestSellerProducts() {

    $bestSellSkus = Yii::$app->controller->module->params['homeBestSellerSku'];
    
  15. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\block\home\Index.php at line 19 – fecshop\app\appfront\modules\Cms\block\home\Index::getFeaturedProduct() 13141516171819202122232425 public function getLastData() {

    $this->initHead();
    // change current layout File.
    //Yii::$service->page->theme->layoutFile = 'home.php';
    return [
        'bestFeaturedProducts'     => $this->getFeaturedProduct(),
        'bestSellerProducts'    => $this->getBestSellerProducts(),
    ];
    

    }

    public function getFeaturedProduct() {

  16. in D:\wamp\www\wordpress\vendor\fancyecommerce\fecshop\app\appfront\modules\Cms\controllers\HomeController.php at line 19 – fecshop\app\appfront\modules\Cms\block\home\Index::getLastData() 13141516171819202122232425 parent::init(); }

    // 网站信息管理 public function actionIndex() {

    $data = $this->getBlock()->getLastData();
    
    return $this->render($this->action->id, $data);
    

    }

    public function behaviors() {

  17. fecshop\app\appfront\modules\Cms\controllers\HomeController::actionIndex()
  18. in D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\InlineAction.php at line 57 – call_user_func_array([fecshop\app\appfront\modules\Cms\controllers\HomeController, 'actionIndex'], [])
  19. in D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\Controller.php at line 157 – yii\base\InlineAction::runWithParams([])
  20. in D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\Module.php at line 528 – yii\base\Controller::runAction('index', [])
  21. in D:\wamp\www\wordpress\vendor\yiisoft\yii2\web\Application.php at line 103 – yii\base\Module::runAction('cms/home/index', [])
  22. in D:\wamp\www\wordpress\vendor\yiisoft\yii2\base\Application.php at line 386 – yii\web\Application::handleRequest(fecshop\yii\web\Request)
  23. in D:\wamp\www\wordpress\appfront\web\index.php at line 87 – yii\base\Application::run() 81828384858687 上面的例子就是获取cms服务的子服务article。 / new fecshop\services\Application($config['services']); unset($config['services']);

$application = new yii\web\Application($config); $application->run(); $_COOKIE = [

'PHPSESSID' => 'gc8r46grouj2gud4em5m0v7dd0',

];

$_SESSION = [

'__flash' => [],
'currency_current' => 'USD',

]; Yii Framework 2017-11-17, 06:36:48

Apache/2.4.23 (Win32) PHP/7.0.10 Yii Framework/2.0.13

Your Site Analytics