magento controller action - magento

I have created the following class on my module
class Mage_Chargeagent_PaymentupdateController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "im here";
die();
}
}
it is located under local\Company\Chargeagent\controllers\PaymentupdateController.php
when im trying to navigate to http://www.xxx.com/index.php/chargeagent/paymentupdate im not getting to the correct action , what am i doing wrong ?

The class name should be Company_Chargeagent_PaymentupdateController
class Company_Chargeagent_PaymentupdateController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "im here";
die();
}
}

Related

Prestashop integrate javascript to custom page

I have created a custom page in Prestashop 1.7.X by using an own controller. How can I load a custom javascript file?
<?php
class MyPageControllerCore extends FrontController{
public $php_self = 'mypage';
public $ssl = true;
public function initContent(){
parent::initContent();
$this->setTemplate('mypage');
}
public function setMedia(){
parent::setMedia();
$this->context->controller->addJS(_THEME_JS_DIR_.'about_us.js');
}
}
Standard way:
1- Generate new module that has frontController
2- Load your custom javascript file from your module
<?php
class ModulenameMypageModuleFrontController extends ModuleFrontController
{
public $php_self = 'mypage';
public $ssl = true;
public function initContent(){
parent::initContent();
$this->setTemplate('mypage.tpl');
}
public function setMedia(){
parent::setMedia();
$this->context->controller->addJS(_PS_MODULE_DIR_.'/views/js/about_us.js');
}
}

Codeigniter modal loaded but functions are not working

I need help.
I'm trying to load a function from a model to a controller.
in my settings.php controller the function is this
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Settings extends CI_Controller {
public function __construct()
{
parent::__construct ();
$this->load->model('update_model');
}
function test_result(){
$this->Update_model->test();
}
}
In my update_model
class Update_model extends CI_Model
{
public function test(){
return 'test1';
}
}
The error is this
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Settings::$update_model
Filename: controllers/settings.php
Line Number: 14
Fatal error: Call to a member function test() on null in C:\xampp\htdocs\activations\application\controllers\settings.php on line 14
Please help.
Thanks
update controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Settings extends CI_Controller {
public function __construct()
{
parent::__construct ();
$this->load->model('update_model');
}
function test_result(){
$this->update_model->test();
}
}
update in Update_model
<?php
class Update_model extends CI_Model
{
function __construct() {
parent::__construct();
}
public function test(){
return 'test1';
}
}
write small first letter when call method of model in controller.$this->update_model->test();

ReflectionException in compiled.php line 1049: Class App\Http\Controllers\User does not exist

i test laravel 5 that i have controller name Usercontroller.php have code:
class UserController extends Controller
{
protected $user = null;
public function __construct(User $user)
{
$this->user = $user;
}
public function allUsers()
{
return $this->user->allUsers();
}
}
and i create model name user.php have code:
class User extends Model
{
public function allUsers()
{
return self::all();
}
}
when i run it show error like below
ReflectionException in compiled.php line 1049: Class App\Http\Controllers\User does not exist
please help me solve about this problem, thanks you.
The User model is found in the namespace App and you have to reference it like that:
public function __construct(\App\User $user)
{
$this->user = $user;
}
Or add an import statement at the top:
use App\User;
class UserController extends Controller

CodeIgniter constructor is not work proper

class model_demo extends CI_Model{
function model_demo()
{
parent::Model();
}
}
I'm working with CodeIgniter with a constructor, and it's producing a fatal error.
class model_demo extends CI_Model{
function model_demo()
{
parent::__construct();
}
If you are using Codeigniter 2 or abore, try:
class model_demo extends CI_Model
{
function __construct()
{
parent::__construct();
}
}
You can see the syntax here:
Models: Codeigniter User guide

CodeIgniter - Call method inside a model?

I have the following code:
class Badge extends CI_Model
{
public function foo()
{
echo $this->bar('world');
}
public function bar($word)
{
return $word;
}
}
But it always gives me an error on the line where echo $this->bar('world'); is.
Call to undefined method (......)
Your not loading your model inside your controller:
public function test()
{
$this->load->model('badge');
$this->badge->foo();
}
Because the code works - I've just tested it by pasting using your model unedited:
class Badge extends CI_Model
{
public function foo()
{
echo $this->bar('world');
}
public function bar($word)
{
return $word;
}
}
output:
world
In order to avoid any external call dependecy you need to get the Codeigniter instance and call the method through the instance.
class Badge extends CI_Model
{
public function foo()
{
$CI =& get_instance();
echo $CI->Badge->bar('world');
}
public function bar($word)
{
return $word;
}
}

Resources