3

I have taken reference of an old module (Bannerslider) created for Magento 2 Beta version and I am trying to convert it to Magento 2 stable compatible (Mycompany_Bannerslider).

When I enable the module and run the following command it doesn't give errors:

bin/magento setup:upgrade

But when I run bin/magento setup:di:compile command then it shows following error in the terminal:

enter image description here

Below is the model-collection file I am using:

namespace Mycompany\Bannerslider\Model\Resource\Banner;
class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
{
        public function __construct()
        {
                $this->_init('Mycompany\Bannerslider\Model\Banner', 'Mycompany\Bannerslider\Model\Resource\Banner');
        }
}
4
  • Are you installed magento 2 release 17/11 ?
    – LinoPham
    Dec 5, 2015 at 10:27
  • Yes the 2.0.0 stable version.
    – Vicky Dev
    Dec 5, 2015 at 10:28
  • You need refactor your module, it can work fine with this version
    – LinoPham
    Dec 5, 2015 at 10:35
  • Please explain what should I do in detail for "refactoring", I recompiled but this error is persistent.
    – Vicky Dev
    Dec 5, 2015 at 10:48

2 Answers 2

3

Change Resource to ResourceModel

namespace Mycompany\Bannerslider\Model\ResourceModel\Banner;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
        public function __construct()
        {
                $this->_init('Mycompany\Bannerslider\Model\Banner', 'Mycompany\Bannerslider\Model\ResourceModel\Banner');
        }
}
4
2

You need refactor your module from Magento2 1.0.0 to Magento2 2.0.0. It included many change, i can list something in the following:

  1. You find and replace all namespace have contain Resource to ResourceModel
  2. Change name Resource folder to ResourceModel in Yourcompany/YourModule/Model
  3. Change all format(xsd) of .xml file in etc folder.
  4. Change Observer/Event(if it exist include: events.xml and path).

...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.