【问题标题】:Getting Fatal error: Cannot redeclare class in magento 2出现致命错误:无法在 magento 2 中重新声明类
【发布时间】:2017-11-01 15:36:58
【问题描述】:

enter code here我创建了一个用于从表中获取数据的模块,但是当我运行该模块时,我收到了一个致命错误,提示 无法重新声明类。我只有一门课叫你好。这是我第一次创建模块,我没有magento 1的经验Link for module source code github

Block\Helloworld.php

    <?php
    namespace Devchannel\Helloworld\Block;


    use Magento\Framework\View\Element\Template\Context;
    use Devchannel\Helloworld\Model\Data;
    use Magento\Framework\View\Element\Template;


    class Hello extends Template
    {

        public function __construct(Context $context, Data $model)
        {
                    $this->model = $model;
            parent::__construct($context);

        }

        public function sayHello()
        {
            return __('Hello World');
        }
            public function getHelloCollection()
            {
                $helloCollection = $this->model->getCollection();
                return $helloCollection;
            }
    }

【问题讨论】:

    标签: php magento magento2 magento2.1


    【解决方案1】:

    将您的班级名称更改为Helloworld。它应该始终与您的文件名匹配。

    【讨论】:

      猜你喜欢
      • 2017-11-25
      • 1970-01-01
      • 2010-10-17
      • 2014-11-07
      • 2012-07-31
      • 2016-03-25
      • 2017-01-21
      • 1970-01-01
      相关资源
      最近更新 更多