2

I have created a crud model for custom table in a module but when i have called that model to do operations I am getting a error

public function __construct(Context $context , \Vendor\Modulename\Model\Doccountmodel $doccountfactory,  Session $customerSession)
    {

        $this->_customerSession = $customerSession;
        $this->doccountfactory = $doccountfactory;
        parent::__construct ( $context );
    }

public function execute(){
  $sampleModel = $this->doccountfactory->create();


    // Load the item with ID is 1
    $item = $sampleModel->load(1);
    var_dump($item->getData());

}
1

Replace in your your __construct signature this

\Vendor\Modulename\Model\Doccountmodel $doccountfactory

with this

\Vendor\Modulename\Model\DoccountmodelFactory $doccountfactory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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