0

This is a screenshot of the error. enter image description here

My code is

app/code/Prayag/Module/view/frontend/layout/cms_index_index.xml

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
       <referenceContainer name="content">
           <block class="Magento\Framework\View\Element\Template"  name="order_total" template="Prayag_Module::orders.phtml">
            </block>
        </referenceContainer>
        <referenceContainer name="sidebar.additional">
    <block class="Magento\Framework\View\Element\Template" name="order_total_sidebar" template="Prayag_Module::orders.phtml">
    </block>
    </referenceContainer>
    <referenceContainer name="content">
    <block class="Magento\Framework\View\Element\Template" name="cart_total_sidebar" template="Prayag_Module::cart_view.phtml">
    </block>
    </referenceContainer>
    </body>
    </page>

app/code/Prayag/Module/view/frontend/templates/orderes.phtml

    <?php

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $customerSession = $objectManager->create('Magento\Customer\Model\Session');
    $customerID = $customerSession->getCustomerId();

    $order = $this->helper('Prayag\Module\Helper\Data')->getCollection($customerID);

    foreach($order as $items){ ?>
    <span>IncrementId :</span><a href="<?php echo $block->getUrl('sales/order/history'); ?>"><?php echo $items->getIncrementId(); ?></a><br>
    <?php
    echo "<b>Subtotal :</b>". $items->getSubtotal(). '<br/>';
    echo "<b>Order Status :</b>". $items->getStatus(). '<br/>';
    echo "<b>Date :</b>". $items->getCreatedAt().'<br/>';

    }

app/code/Prayag/Module/Helper/Data.php

    <?php
    namespace Prayag\Module\Helper;
    class Data extends \Magento\Framework\App\Helper\AbstractHelper
    {
    public function __construct(
    \Magento\Sales\Model\OrderFactory $orderFactory
    ) {
    $this->orderFactory = $orderFactory;
    }
    public function getCollection($customerID)
    {
    $collection = $this->orderFactory->create()->getCollection()->setOrder('entity_id', 'DESC')
    ->addAttributeToFilter('customer_id',$customerID);
    $collection->setPageSize(5)->setCurPage(1);
    return $collection;
    }
    }
  • 1
    Post your helper here and the error shows that getLabel function doesn't exist there in heper file – Prathap Gunasekaran Apr 16 '19 at 11:36
  • where should I put that ?? – Prayag Dave Apr 16 '19 at 11:40
  • have you checked cart_view.phtml ?? – Ghulam.M Apr 16 '19 at 11:58
0

It seems everything is correct in the above code, but the error shows that getLabel function from helper is missing and you're calling it somewhere around in home page.

By resolve this just try add

public function getLabel(){
}

to the helper or run the below commands.

rm -rf generated
php bin/magento cac:flu

Hope this helps.

| improve this answer | |
  • Yes, It's help me. Thank you. – Prayag Dave Apr 16 '19 at 11:57

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.