1

trying to create a new model class to be used as a source model for the admin configuration setting of a new module, I got the following 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...')

Could you please help me in understanding what's wrong considering the following files?

in my ..\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>

and my ..\wamp\www\magento\app\code\makke\module-group-orders\Model\Config\Source\Sort.php is as follow:

/**
 * 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')];
 }
}
Utsav Gupta
1,2431 gold badge20 silver badges52 bronze badges
asked Mar 28, 2016 at 18:23

2 Answers 2

0

Please try to change your file name (Sort.php) to other name, Sort is a php keyword name then you cannot use this name for a class name

answered Mar 29, 2016 at 6:49
0

You should rename app\code\makke\module-group-orders folder to app\code\Makke\GroupOrders

answered Nov 6, 2022 at 18:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.