For Magento 2. You can use below CRUD generator
While developing a Sample module for test CRUD operation ,It shows below error but i have the model in the folder
Class United\Sample\Model\ResourcModel\News does not exist
#0 D:\xampp\htdocs\magento2\vendor\magento\framework\Code\Reader\ClassReader.php(19): ReflectionClass->__construct('United\\Sample\\M...')
#1 D:\xampp\htdocs\magento2\vendor\magento\framework\ObjectManager\Definition\Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('United\\Sample\\M...')
My model News.php inside app\code\United\Sample\Model\ResourceModel
<?php
namespace United\Sample\Model\ResourceModel;
class News extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
protected $_date;
/**
* Construct
*
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
* @param string|null $resourcePrefix
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
$resourcePrefix = null
) {
parent::__construct($context, $resourcePrefix);
$this->_date = $date;
}
/**
* Define main table
*/
protected function _construct()
{
$this->_init('united_sample', 'id');
}
public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null)
{
if (!is_numeric($value) && is_null($field)) {
$field = 'id';
}
return parent::load($object, $value, $field);
}
}
The source of your problem is an illiterate string "ResourcModel".
Do global code search for it.
Hi All!
Seems to have the same issue but I have checked every strings and they are ok; the error message:
Class Makke\GroupOrders\Model\Config\Source\Sort does not exist
#0 C:\Projects\Marketplace\wamp\www\magento\vendor\magento\framework\Code\Reader\ClassReader.php(19): ReflectionClass->__construct('Makke\\GroupOrde...')
#1 C:\Projects\Marketplace\wamp\www\magento\vendor\magento\framework\ObjectManager\Definition\Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Makke\\GroupOrde...')
#2 C:\Projects\Marketplace\wamp\www\magento\vendor\magento\framework\ObjectManager\Factory\Dynamic\Developer.php(71): Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Makke\\GroupOrde...')
in "..\wamp\www\magento\app\code\makke\module-group-orders\etc\adminhtml\system.xml" there is the following field:
<field id="sort_mode" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort by</label>
<source_model>Makke\GroupOrders\Model\Config\Source\Sort</source_model>
</field>
my "..\wamp\www\magento\app\code\makke\module-group-orders\Model\Config\Source\Sort.php" is as follow:
<?php
/**
* Copyright © 2016 Makke. All rights reserved.
*/
/**
* Used in creating options for Sort config value selection
*
*/
namespace Makke\GroupOrders\Model\Config\Source;
class Sort implements \Magento\Framework\Option\ArrayInterface
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return [['value' => 'asc_by_km', 'label' => __('ASC by km')],
['value' => 'desc_by_km', 'label' => __('DESC by km')],
['value' => 'asc_by_popularity', 'label' => __('ASC by popularity')],
['value' => 'desc_by_popularity', 'label' => __('DESC by popularity')]];
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
return ['asc_by_km' => __('ASC by km'),
'desc_by_km' => __('DESC by km'),
'asc_by_popularity' => __('ASC by popularity'),
'desc_by_popularity' => __('DESC by popularity')];
}
}
It seems like your custom Makke_GroupOrders extension is not properly installed.
For Magento 2. You can use below CRUD generator