1
 $_helper = $this->helper('catalog/output');

i received this error on browser when I run the code.

Using $this when not in object context in C:\xampp\htdocs\magento\test.php

What should i do for this .

3

you should have this:

require_once('app/Mage.php');
        $app = Mage::app();
        Mage::helper('catalog/output');

Basically the $this->helper is calling the function that is contained inside the current template's block class. The Mage::helper is calling the function in the "God" class.

The $this->helper normally calls a function in the class Mage_Core_Block_Abstract which checks the layout for a helper and then simply calls the normal Mage::helper if it cannot find one.

1

I think you are creating a stand alone script.

so you can try below things to work

require_once("$Magento_Root_DIR/app/Mage.php"); // include Mage.php file 
$app = Mage::app(); //init Mage::app()
$_helper = Mage::helper('catalog/output'); //calling helper class

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.