I have a helper class with parameter as shown below. I need this function to work on a specific controller. But returns this error. My helper Code below

namespace Rk\Wallet\Helper;

class DataPlaceOrder extends \Magento\Framework\App\Helper\AbstractHelper
    * @param Magento\Framework\App\Helper\Context $context
    * @param Magento\Store\Model\StoreManagerInterface $storeManager
    * @param Magento\Catalog\Model\Product $product
    * @param Magento\Framework\Data\Form\FormKey $formKey $formkey,
    * @param Magento\Quote\Model\Quote $quote,
    * @param Magento\Customer\Model\CustomerFactory $customerFactory,
    * @param Magento\Sales\Model\Service\OrderService $orderService,
    public function __construct(
        \Magento\Framework\App\Helper\Context $context,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Catalog\Model\Product $product,
        \Magento\Framework\Data\Form\FormKey $formkey,
        \Magento\Quote\Model\QuoteFactory $quote,
        \Magento\Quote\Model\QuoteManagement $quoteManagement,
        \Magento\Customer\Model\CustomerFactory $customerFactory,
        \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
        \Magento\Sales\Model\Service\OrderService $orderService  
    ) {
        $this->_storeManager = $storeManager;
        $this->_product = $product;
        $this->_formkey = $formkey;
        $this->quote = $quote;
        $this->quoteManagement = $quoteManagement;
        $this->customerFactory = $customerFactory;
        $this->customerRepository = $customerRepository;
        $this->orderService = $orderService;

     * Create Order On Your Store
     * @param array $orderData
     * @return array

    public function createMageOrder($orderData) {
        $websiteId = $this->_storeManager->getStore()->getWebsiteId();
        $customer->loadByEmail($orderData['email']);// load customet by email address
            //If not avilable then create this customer 
        $quote=$this->quote->create(); //Create object of quote
        $quote->setStore($store); //set store for which you create quote
        // if you have allready buyer id then you can load customer directly 
        $customer= $this->customerRepository->getById($customer->getEntityId());
        $quote->assignCustomer($customer); //Assign quote to customer

        //add items in quote
        foreach($orderData['items'] as $item){

        //Set Address to quote

        // Collect Rates and Set Shipping & Payment Method

                        ->setShippingMethod('freeshipping_freeshipping'); //shipping method
        $quote->setPaymentMethod('payu'); //payment method
        $quote->setInventoryProcessed(false); //not effetc inventory
        $quote->save(); //Now Save quote and your quote is ready

        // Set Sales Order Payment
        $quote->getPayment()->importData(['method' => 'payu']);

        // Collect Totals & Save Quote

        // Create Order From Quote
        $order = $this->quoteManagement->submit($quote);

        $increment_id = $order->getRealOrderId();
            $result['order_id']= $order->getRealOrderId();
            $result=['error'=>1,'msg'=>'Your custom message'];
        return $result;

My controller


namespace Rk\Wallet\Controller\Index;

class Wallet extends \Magento\Framework\App\Action\Action
public function execute()


But return the following error

Warning: Missing argument 1 for Rk\Wallet\Helper\DataPlaceOrder::createMageOrder(), called in /home/rkhomeappliances/public_html/test/app/code/Rk/Wallet/Controller/Index/Wallet.php on line 63 and defined in /home/rkhomeappliances/public_html/test/app/code/Rk/Wallet/Helper/DataPlaceOrder.php on line 48

  • Your helper function is called here but issue is you are not passing any argument while calling helper function and you have defined $data in helper function so its make issues Jan 31, 2018 at 6:50
  • $orderdata? So how to call this arguement in controller?
    – Ramesh KR
    Jan 31, 2018 at 6:51
  • in your controller change like this - $this->helperData->createMageOrder($orderData); Jan 31, 2018 at 6:51
  • no it return undefined variable
    – Ramesh KR
    Jan 31, 2018 at 7:12

3 Answers 3


Looks like your call to helper is alright, the issue with you code is you helper method createMageOrder needs one argument $orderData, and in controller where you called the helper method $this->helperData->createMageOrder(); you missed to provide required parameter.

Provide the required parameter in hepler method call and you are good to go

$orderData = [...]; // Prepare $orderData and pass in helper method call 
  • what to give inside $orderdata[???] pls help me
    – Ramesh KR
    Jan 31, 2018 at 7:23
  • create $orderdata array with all the data you need. Jan 31, 2018 at 9:24
     * @var Vendor\Module\Helper\Data
    protected $_Customhelper;

public function __construct(\Vendor\Module\Helper\Data $Customhelper)
     $this->_Customhelper = $Customhelper;

user by this syntax::

  • My helper has an argument public function createMageOrder($orderData) {} it returns argument missing error
    – Ramesh KR
    Jan 31, 2018 at 7:14
  • You can call function with argument like $this->_Customhelper->createMageOrder($orderData); Jan 31, 2018 at 8:37

try this

namespace Rk\Wallet\Controller\Index;

use \Magento\Framework\App\Action\Action;
use \Magento\Framework\App\Action\Context;
use \Rk\Wallet\Helper\Data;

class Help extends Action
    protected $helper;

    public function __construct(
        Context $context,
        Data $helper
    ) {
        $this->helper = $helper;
    public function execute()
  • My helper has an argument public function createMageOrder($orderData) {} it returns argument missing error
    – Ramesh KR
    Jan 31, 2018 at 7:13
  • now check updated code Jan 31, 2018 at 7:54

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.