0

If anyone have idea then please share with me.

I am going to stuck in this error:

Uncaught Error: Undefined constant 'Product\SizeChart\Helper\Data' in /opt/lampp/htdocs/M2/app/code/Product/SizeChart/view/frontend/templates/size.phtml:48 Stack trace: #0 /opt/lampp/htdocs/M2/vendor/magento/framework/View/TemplateEngine/Php.php(59): include() #1 /opt/lampp/htdocs/M2/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\TemplateEngine\Php->render(Object(Product\SizeChart\Block\Display), '/opt/lampp/htdo...', Array) #2 /opt/lampp/htdocs/M2/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent('render', Array) #3 /opt/lampp/htdocs/M2/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception{closure}(Object(Product\SizeChart\Block\Display), '/opt/lampp/htdo...', Array) #4 /opt/lampp/htdocs/M2/generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php(26): Magento\Framework\View\TemplateEngine\ in /opt/lampp/htdocs/M2/app/code/Product/SizeChart/view/frontend/templates/size.phtml on line 48

here is my helper code:

<?php namespace Product\SizeChart\Helper;

use \Magento\Framework\App\Action\Context;
use \Product\SizeChart\Model\CurdFactory;

class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
    protected $curdFactory;
    
    public function __construct(
        Context $context,
        CurdFactory $curdFactory,
        $data = []
    )     {
        $this->curdFactory = $curdFactory;
        parent::__construct($context, $data);
    }
    
    public function getCollection()
    {
        return $this->curdFactory->create()->getCollection();
    }
}

Thank you in Advance.

1
  • please check my answer and update me. – Msquare Jul 15 '20 at 9:33
1

Try to add below line in your helper class after namespace line, I think you're using Context anywhere in your constructor and there you only used Context $context and that context file is not available with your Helper file's location here Product\SizeChart\Helper\Context. So you can define that file's path like below..

namespace Product\SizeChart\Helper;

use Magento\Framework\App\Helper\Context;

Hope this will help you!

0

If you don't have any issue with your code then just kindly Remove generated folder form root directory of you magento and then run setup:di:Compile and flush cache.

Hope this helps!

0

Try this

<?php 

namespace Product\SizeChart\Helper;

use \Magento\Framework\App\Helper\AbstractHelper;

class Data extends AbstractHelper
{
    protected $curdFactory;

    public function __construct(
        \Product\SizeChart\Model\ResourceModel\Curd\CollectionFactory $curdFactory
    ) {
        $this->curdFactory = $curdFactory;
    }
    public function getCollection()
    {
        return $this->curdFactory->create();
    }
}

Must be run Magento upgrade command

I Hope This Helps You

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.